chiark / gitweb /
JPEG support and other fixes from Nick Clark
[ssr] / StraySrc / Libraries / Sapphire / s / mem
1 ;
2 ; mem.s
3 ;
4 ; Operations on memory blocks (TMA)
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Standard header ------------------------------------------------------
28
29                 GET     libs:swis
30                 GET     libs:header
31
32 ;----- External dependencies ------------------------------------------------
33 ;
34 ; None.
35
36 ;----- Main code ------------------------------------------------------------
37
38                 AREA    |Sapphire$$Code|,CODE,READONLY
39
40 ; --- mem_set ---
41 ;
42 ; On entry:     R0 == pointer to a block of memory (word-aligned)
43 ;               R1 == size of the block
44 ;               R2 == word value to store in the block
45 ;
46 ; On exit:      --
47 ;
48 ; Use:          Initialises a block by filling every word within it with the
49 ;               same value.  This is normally 0, although maybe MOVS PC,#0
50 ;               might be useful too.
51
52                 EXPORT  mem_set
53 mem_set         ROUT
54
55                 STMFD   R13!,{R0-R8,R14}        ;Stack registers away
56
57                 ; --- Set up seed value in lots of registers ---
58
59                 MOV     R3,R2
60                 MOV     R4,R2
61                 MOV     R5,R2
62                 MOV     R6,R2
63                 MOV     R7,R2
64                 MOV     R8,R2
65                 MOV     R14,R2
66
67                 ; --- Do the copy ---
68
69 00mem_set       SUBS    R1,R1,#32               ;Is there enough for fastblat
70                 STMGEIA R0!,{R2-R8,R14}         ;Yes -- *blat*
71                 BGE     %00mem_set
72
73                 ; --- Now to word blats ---
74
75                 ADD     R1,R1,#32               ;How much left to do?
76 01mem_set       SUBS    R1,R1,#4                ;Enough for a word?
77                 STRGE   R14,[R0],#4             ;Yes -- store it
78                 BGE     %01mem_set              ;And go round again
79
80                 LDMFD   R13!,{R0-R8,PC}^        ;Return to caller
81
82                 LTORG
83
84 ;----- That's all folks -----------------------------------------------------
85
86                 END