[go: up one dir, main page]

Menu

[a3f5d0]: / EDGEASM.S  Maximize  Restore  History

Download this file

208 lines (190 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
;
; edgeasm.s
;
; implements:
; void cold_boot(void)
; void fast_copy(void *to,void *from,long size)
;
; define SHORTINT iff you are compiling with short ints
;
;
; revised by rfb nov/2002:
; . improve fast_copy() speed by handling 68000/68030 differently
; (among other things)
; . change order of fast_copy() args to be the same as as memcpy
;
memvalid equ $420
resvalid equ $426
_sysbase equ $4f2
section text
xdef _cold_boot,_fast_copy
xref _cpu_type
;
; cold_boot
;
_cold_boot:
clr.l -(sp)
move.w #$20,-(sp)
trap #1
addq #6,sp
move.l _sysbase,a0
clr.l memvalid
clr.l resvalid
jmp (a0)
;
; fast_copy
;
_fast_copy:
move.l 4(a7),a1
move.l 8(a7),a0
move.l 12(a7),d0
beq.b exit
;
; setting up for the different types of copy is in itself costly,
; so it makes sense to just do a simple copy for small counts.
; by experiment, we choose a cut-off point of 32.
;
cmpi.l #32,d0
blo finish
;
; processing depends on cpu type ...
;
cmpi.w #30,_cpu_type
bcc handle_68030
;
; *** handle 68000 (& 68010, 68020 ...) ***
;
;
; copy 1 byte if a0 is not word aligned
;
move.l a0,d2
andi.b #1,d2
beq.b choose_copy_size
move.b (a0)+,(a1)+
subq.l #1,d0
;
; we have to perform a copy: choose the move routine(s)
; based on the alignment of a1
;
choose_copy_size:
move.l a1,d2
andi.b #1,d2
beq.b copyword
bra.b copybyte
;
; *** handle 68030 (& 68040, 68060 ...) ***
;
handle_68030:
;
; for 68030 and above, there is no requirement for long-word accesses
; to be aligned. for these systems we do as many longword copies as
; possible, followed by word copies, followed by byte copies
;
copylong:
bsr copy_by_longword
copyword:
bsr copy_by_word
copybyte:
bsr copy_by_byte
;
; the following rolled, single-byte copy loop finishes off the copy
;
finish:
bra.b decrement
copy_1_byte:
move.b (a0)+,(a1)+
decrement:
dbra d0,copy_1_byte
exit:
rts
;
;Note: In an earlier version of this module, the faster DBRA instruction
; was used. However, it imposed a maximum of (2^15-1)*16 on src_len
; so I changed it to the sub/bne combination. I suppose I could have
; nested DBRAs but this is simpler and not much slower.
;
copy_by_byte:
move.l d0,d1
lsr.l #4,d1
beq.b copybyte_exit
move.l d1,d2
lsl.l #4,d2
sub.l d2,d0
copy_16_bytes:
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
move.b (a0)+,(a1)+
subq.l #1,d1
bne.b copy_16_bytes
copybyte_exit:
rts
copy_by_word:
move.l d0,d1
lsr.l #5,d1
beq.b copyword_exit
move.l d1,d2
lsl.l #5,d2
sub.l d2,d0
copy_16_words:
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
move.w (a0)+,(a1)+
subq.l #1,d1
bne.b copy_16_words
copyword_exit:
rts
copy_by_longword:
move.l d0,d1
lsr.l #6,d1
beq.b copylong_exit
move.l d1,d2
lsl.l #6,d2
sub.l d2,d0
copy_16_longwords:
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
subq.l #1,d1
bne.b copy_16_longwords
copylong_exit:
rts
end