summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire')
-rwxr-xr-xfirmware/target/coldfire/memcpy-coldfire.S680
-rwxr-xr-xfirmware/target/coldfire/memmove-coldfire.S668
-rwxr-xr-xfirmware/target/coldfire/memset-coldfire.S150
-rwxr-xr-xfirmware/target/coldfire/memset16-coldfire.S144
4 files changed, 1642 insertions, 0 deletions
diff --git a/firmware/target/coldfire/memcpy-coldfire.S b/firmware/target/coldfire/memcpy-coldfire.S
new file mode 100755
index 0000000000..523e1f5ed9
--- /dev/null
+++ b/firmware/target/coldfire/memcpy-coldfire.S
@@ -0,0 +1,680 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004-2005 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21 .section .icode,"ax",@progbits
22
23#define FULLSPEED /* use burst writing for word aligned destinations */
24 .align 2
25 .global memcpy
26 .global __memcpy_fwd_entry
27 .type memcpy,@function
28
29/* Copies <length> bytes of data in memory from <source> to <dest>
30 * This version is optimized for speed
31 *
32 * arguments:
33 * (4,%sp) - destination address
34 * (8,%sp) - source address
35 * (12,%sp) - length
36 *
37 * return value:
38 * %d0 - destination address (like ANSI version)
39 *
40 * register usage:
41 * %a0 - current source address
42 * %a1 - current dest address
43 * %a2 - source end address (in line-copy loops)
44 * %d0 - data / scratch
45 * %d1 - source end address (byte and longword copy) / data / scratch
46 * %d2 - data / scratch
47 * %d3..%d7 - data
48 *
49 * For maximum speed this routine reads and writes whole lines using burst
50 * move (movem.l) where possible. For byte aligned destinations (long+1 and
51 * long+3) it writes longwords only. Same goes for word aligned destinations
52 * if FULLSPEED is undefined.
53 */
54memcpy:
55 move.l (4,%sp),%a1 /* Destination */
56 move.l (8,%sp),%a0 /* Source */
57 move.l (12,%sp),%d1 /* Length */
58
59__memcpy_fwd_entry:
60 add.l %a0,%d1 /* %d1 = source end */
61
62 move.l %a0,%d0
63 addq.l #7,%d0
64 and.l #0xFFFFFFFC,%d0 /* %d0 = first source long bound + 4 */
65 cmp.l %d0,%d1 /* at least one aligned longword to copy? */
66 blo.w .bytes2_start /* no, jump directly to trailing byte loop */
67
68 subq.l #4,%d0 /* %d0 = first source long bound */
69 cmp.l %a0,%d0 /* any bytes to copy? */
70 jls .bytes1_end /* no: skip byte loop */
71
72 /* leading byte loop: copies 0..3 bytes */
73.bytes1_loop:
74 move.b (%a0)+,(%a1)+ /* copy byte */
75 cmp.l %a0,%d0 /* runs %a0 up to first long bound */
76 jhi .bytes1_loop
77
78.bytes1_end:
79 moveq.l #31,%d0
80 add.l %a0,%d0
81 and.l #0xFFFFFFF0,%d0 /* %d0 = first source line bound + 16 */
82 cmp.l %d0,%d1 /* at least one aligned line to copy? */
83 blo.w .long_start /* no: jump to longword copy loop */
84
85 lea.l (-28,%sp),%sp /* free up some registers */
86 movem.l %d2-%d7/%a2,(%sp)
87
88 moveq.l #16,%d2
89 sub.l %d2,%d0 /* %d0 = first source line bound */
90 move.l %d1,%a2 /* %a2 = end address */
91 lea.l (-15,%a2),%a2 /* adjust end address for loops doing 16 bytes/ pass */
92 move.l %a1,%d1
93 moveq.l #3,%d2 /* mask */
94 and.l %d2,%d1
95 jmp.l (2,%pc,%d1.l*4) /* switch (dest_addr & 3) */
96 bra.w .lines_do0_start
97 bra.w .lines_do1_start
98 bra.w .lines_do2_start
99 /* bra.w .lines_do3_start implicit */
100
101 /* byte aligned destination (long + 3): use line burst reads in main loop */
102.lines_do3_start:
103 moveq.l #24,%d1 /* shift count for shifting by 3 bytes */
104 cmp.l %a0,%d0 /* any leading longwords? */
105 jhi .lines_do3_head_start /* yes: leading longword copy */
106
107 movem.l (%a0),%d4-%d7 /* load first line */
108 lea.l (16,%a0),%a0
109 move.l %d4,%d2
110 lsr.l %d1,%d2 /* get high byte of first longword */
111 move.b %d2,(%a1)+ /* store byte */
112 jra .lines_do3_entry /* jump into main loop */
113
114.lines_do3_head_start:
115 move.l (%a0)+,%d7 /* load first longword */
116 move.l %d7,%d2
117 lsr.l %d1,%d2 /* get high byte */
118 move.b %d2,(%a1)+ /* store byte */
119 jra .lines_do3_head_entry /* jump into leading longword loop */
120
121.lines_do3_head_loop:
122 move.l %d7,%d6 /* move old longword away */
123 move.l (%a0)+,%d7 /* load new longword */
124 move.l %d7,%d2
125 lsr.l %d1,%d2 /* get high byte */
126 or.l %d2,%d6 /* combine with old lower 3 bytes */
127 move.l %d6,(%a1)+ /* store longword */
128.lines_do3_head_entry:
129 lsl.l #8,%d7 /* shift up lower 3 bytes */
130 cmp.l %a0,%d0 /* runs %a0 up to first line bound */
131 jhi .lines_do3_head_loop
132
133.lines_do3_loop:
134 move.l %d7,%d3 /* move last longword of old line away */
135 movem.l (%a0),%d4-%d7 /* load new line */
136 lea.l (16,%a0),%a0
137 move.l %d4,%d2
138 lsr.l %d1,%d2 /* get high byte of 1st longword */
139 or.l %d2,%d3 /* combine with old lower 3 bytes */
140 move.l %d3,(%a1)+ /* store longword */
141.lines_do3_entry:
142 lsl.l #8,%d4 /* shift up lower 3 bytes */
143 move.l %d5,%d2
144 lsr.l %d1,%d2 /* get high byte of 2nd longword */
145 or.l %d2,%d4 /* combine with 1st lower 3 bytes */
146 move.l %d4,(%a1)+ /* store longword */
147 lsl.l #8,%d5 /* shift up lower 3 bytes */
148 move.l %d6,%d2
149 lsr.l %d1,%d2 /* get high byte of 3rd longword */
150 or.l %d2,%d5 /* combine with 2nd lower 3 bytes */
151 move.l %d5,(%a1)+ /* store longword */
152 lsl.l #8,%d6 /* shift up lower 3 bytes */
153 move.l %d7,%d2
154 lsr.l %d1,%d2 /* get high byte of 4th longword */
155 or.l %d2,%d6 /* combine with 3rd lower 3 bytes */
156 move.l %d6,(%a1)+ /* store longword */
157 lsl.l #8,%d7 /* shift up lower 3 bytes */
158 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
159 jhi .lines_do3_loop
160
161 lea.l (12,%a2),%a2 /* readjust end address for doing longwords */
162 cmp.l %a0,%a2 /* any trailing longwords? */
163 jls .lines_do3_tail_end /* no: just store last lower 3 bytes */
164
165.lines_do3_tail_loop:
166 move.l %d7,%d6 /* move old longword away */
167 move.l (%a0)+,%d7 /* load new longword */
168 move.l %d7,%d2
169 lsr.l %d1,%d2 /* get high byte */
170 or.l %d2,%d6 /* combine with old lower 3 bytes */
171 move.l %d6,(%a1)+ /* store longword */
172 lsl.l #8,%d7 /* shift up lower 3 bytes */
173 cmp.l %a0,%a2 /* runs %a0 up to last long bound */
174 jhi .lines_do3_tail_loop
175
176.lines_do3_tail_end:
177 swap %d7 /* get high word */
178 move.w %d7,(%a1)+ /* store word */
179 lsr.l %d1,%d7 /* get moved-up low byte */
180 move.b %d7,(%a1)+ /* store byte */
181 jra .lines_end
182
183 /* byte aligned destination (long + 1): use line burst reads in main loop */
184.lines_do1_start:
185 moveq.l #24,%d1 /* shift count for shifting by 3 bytes */
186 cmp.l %a0,%d0 /* any leading longwords? */
187 jhi .lines_do1_head_start /* yes: leading longword copy */
188
189 movem.l (%a0),%d4-%d7 /* load first line */
190 lea.l (16,%a0),%a0
191 move.l %d4,%d2 /* first longword, bytes 3210 */
192 lsr.l #8,%d2 /* first longword, bytes .321 */
193 swap %d2 /* first longword, bytes 21.3 */
194 move.b %d2,(%a1)+ /* store byte */
195 swap %d2 /* first longword, bytes .321 */
196 move.w %d2,(%a1)+ /* store word */
197 jra .lines_do1_entry
198
199.lines_do1_head_start:
200 move.l (%a0)+,%d7 /* load first longword */
201 move.l %d7,%d2 /* first longword, bytes 3210 */
202 lsr.l #8,%d2 /* first longword, bytes .321 */
203 swap %d2 /* first longword, bytes 21.3 */
204 move.b %d2,(%a1)+ /* store byte */
205 swap %d2 /* first longword, bytes .321 */
206 move.w %d2,(%a1)+ /* store word */
207 jra .lines_do1_head_entry
208
209.lines_do1_head_loop:
210 move.l %d7,%d6 /* move old longword away */
211 move.l (%a0)+,%d7 /* load new longword */
212 move.l %d7,%d2
213 lsr.l #8,%d2 /* get upper 3 bytes */
214 or.l %d2,%d6 /* combine with old low byte */
215 move.l %d6,(%a1)+ /* store longword */
216.lines_do1_head_entry:
217 lsl.l %d1,%d7 /* shift up low byte */
218 cmp.l %a0,%d0 /* runs %a0 up to first line bound */
219 jhi .lines_do1_head_loop
220
221.lines_do1_loop:
222 move.l %d7,%d3 /* move last longword of old line away */
223 movem.l (%a0),%d4-%d7 /* load new line */
224 lea.l (16,%a0),%a0
225 move.l %d4,%d2
226 lsr.l #8,%d2 /* get upper 3 bytes of 1st longword */
227 or.l %d2,%d3 /* combine with low byte of old longword */
228 move.l %d3,(%a1)+ /* store longword */
229.lines_do1_entry:
230 lsl.l %d1,%d4 /* shift up low byte */
231 move.l %d5,%d2
232 lsr.l #8,%d2 /* get upper 3 bytes of 2nd longword */
233 or.l %d2,%d4 /* combine with low byte of 1st longword */
234 move.l %d4,(%a1)+ /* store longword */
235 lsl.l %d1,%d5 /* shift up low byte */
236 move.l %d6,%d2
237 lsr.l #8,%d2 /* get upper 3 bytes of 3rd longword */
238 or.l %d2,%d5 /* combine with low byte of 2nd longword */
239 move.l %d5,(%a1)+ /* store longword */
240 lsl.l %d1,%d6 /* shift up low byte */
241 move.l %d7,%d2
242 lsr.l #8,%d2 /* get upper 3 bytes of 4th longword */
243 or.l %d2,%d6 /* combine with low byte of 4th longword */
244 move.l %d6,(%a1)+ /* store longword */
245 lsl.l %d1,%d7 /* shift up low byte */
246 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
247 jhi .lines_do1_loop
248
249 lea.l (12,%a2),%a2 /* readjust end address for doing longwords */
250 cmp.l %a0,%a2 /* any trailing longwords? */
251 jls .lines_do1_tail_end /* no: just store last low byte */
252
253.lines_do1_tail_loop:
254 move.l %d7,%d6 /* move old longword away */
255 move.l (%a0)+,%d7 /* load new longword */
256 move.l %d7,%d2
257 lsr.l #8,%d2 /* get upper 3 bytes */
258 or.l %d2,%d6 /* combine with old low byte */
259 move.l %d6,(%a1)+ /* store longword */
260 lsl.l %d1,%d7 /* shift up low byte */
261 cmp.l %a0,%a2 /* runs %a0 up to last long bound */
262 jhi .lines_do1_tail_loop
263
264.lines_do1_tail_end:
265 lsr.l %d1,%d7 /* get shifted-up low byte */
266 move.b %d7,(%a1)+ /* store byte */
267 jra .lines_end
268
269 /* long aligned destination (line + 0/4/8/12): head */
270.lines_do0_head_loop:
271 move.l (%a0)+,(%a1)+ /* copy longword */
272.lines_do0_start:
273 cmp.l %a0,%d0 /* runs %a0 up to first line bound */
274 jhi .lines_do0_head_loop
275
276.lines_do0_head_end:
277 move.l %a1,%d1
278 lsr.l #2,%d1
279 moveq.l #3,%d0 /* mask */
280 and.l %d0,%d1
281 moveq.l #16,%d0 /* address increment for one main loop pass */
282 jmp.l (2,%pc,%d1.l*2) /* switch ((dest_addr >> 2) & 3) */
283 bra.b .lines_lo0_start
284 bra.b .lines_lo4_start
285 bra.b .lines_lo8_start
286 /* bra.b .lines_lo12_start implicit */
287
288 /* long aligned destination (line + 12): use line bursts in the loop */
289.lines_lo12_start:
290 movem.l (%a0),%d4-%d7 /* load first line */
291 add.l %d0,%a0
292 move.l %d4,(%a1)+ /* store 1st longword */
293 cmp.l %a0,%a2 /* any full lines? */
294 jls .lines_lo12_end /* no: skip main loop */
295
296.lines_lo12_loop:
297 move.l %d5,%d1 /* move last 3 longwords of old line away */
298 move.l %d6,%d2
299 move.l %d7,%d3
300 movem.l (%a0),%d4-%d7 /* load new line */
301 add.l %d0,%a0
302 movem.l %d1-%d4,(%a1) /* store line (3 old + 1 new longwords) */
303 add.l %d0,%a1
304 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
305 jhi .lines_lo12_loop
306
307 /* long aligned destination (line + 0/4/8/12): tail */
308.lines_lo12_end:
309 move.l %d5,(%a1)+ /* store 3rd last longword */
310.lines_lo8_end:
311 move.l %d6,(%a1)+ /* store 2nd last longword */
312.lines_lo4_end:
313 move.l %d7,(%a1)+ /* store last longword */
314.lines_lo0_end:
315 lea.l (12,%a2),%a2 /* readjust end address for doing longwords */
316 cmp.l %a0,%a2 /* any trailing longwords? */
317 jls .lines_end /* no: get outta here */
318
319.lines_do0_tail_loop:
320 move.l (%a0)+,(%a1)+ /* copy longword */
321 cmp.l %a0,%a2 /* runs %a0 up to last long bound */
322 jhi .lines_do0_tail_loop
323
324 jra .lines_end
325
326 /* line aligned destination: use line bursts in the loop */
327.lines_lo0_start:
328.lines_lo0_loop:
329 movem.l (%a0),%d4-%d7 /* load line */
330 add.l %d0,%a0
331 movem.l %d4-%d7,(%a1) /* store line */
332 add.l %d0,%a1
333 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
334 jhi .lines_lo0_loop
335
336 jra .lines_lo0_end /* handle trailing longwords */
337
338 /* long aligned destination (line + 4): use line bursts in the loop */
339.lines_lo4_start:
340 movem.l (%a0),%d4-%d7 /* load first line */
341 add.l %d0,%a0
342 move.l %d4,(%a1)+ /* store 1st longword */
343 move.l %d5,(%a1)+ /* store 2nd longword */
344 move.l %d6,(%a1)+ /* store 3rd longword */
345 cmp.l %a0,%a2 /* any full lines? */
346 jls .lines_lo4_end /* no: skip main loop */
347
348.lines_lo4_loop:
349 move.l %d7,%d3 /* move last longword of old line away */
350 movem.l (%a0),%d4-%d7 /* load new line */
351 add.l %d0,%a0
352 movem.l %d3-%d6,(%a1) /* store line (1 old + 3 new longwords) */
353 add.l %d0,%a1
354 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
355 jhi .lines_lo4_loop
356
357 jra .lines_lo4_end /* handle trailing longwords */
358
359 /* long aligned destination (line + 8): use line bursts in the loop */
360.lines_lo8_start:
361 movem.l (%a0),%d4-%d7 /* load first line */
362 add.l %d0,%a0
363 move.l %d4,(%a1)+ /* store 1st longword */
364 move.l %d5,(%a1)+ /* store 2nd longword */
365 cmp.l %a0,%a2
366 jls .lines_lo8_end
367
368.lines_lo8_loop:
369 move.l %d6,%d2 /* move last 2 longwords of old line away */
370 move.l %d7,%d3
371 movem.l (%a0),%d4-%d7 /* load new line */
372 add.l %d0,%a0
373 movem.l %d2-%d5,(%a1) /* store line (2 old + 2 new longwords) */
374 add.l %d0,%a1
375 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
376 jhi .lines_lo8_loop
377
378 jra .lines_lo8_end /* handle trailing longwords */
379
380#ifdef FULLSPEED
381
382 /* word aligned destination (line + 2/6/10/14): head */
383.lines_do2_start:
384 cmp.l %a0,%d0 /* any leading longwords? */
385 jls .lines_do2_selector /* no: jump to mainloop selector */
386
387 move.l (%a0)+,%d7 /* load first longword */
388 swap %d7 /* swap words */
389 move.w %d7,(%a1)+ /* store high word */
390 cmp.l %a0,%d0 /* any more longword? */
391 jls .lines_do2_head_end /* no: skip head loop */
392
393.lines_do2_head_loop:
394 move.l %d7,%d6 /* move old longword away */
395 move.l (%a0)+,%d7 /* load new longword */
396 swap %d7 /* swap words */
397 move.w %d7,%d6 /* combine high word with old low word */
398 move.l %d6,(%a1)+ /* store longword */
399 cmp.l %a0,%d0 /* runs %a0 up to first line bound */
400 jhi .lines_do2_head_loop
401
402.lines_do2_head_end:
403 swap %d7 /* undo swap */
404 move.w %d7,(%a1)+ /* store word */
405
406.lines_do2_selector:
407 move.l %a1,%d1
408 lsr.l #2,%d1
409 moveq.l #3,%d0 /* mask */
410 and.l %d0,%d1
411 moveq.l #16,%d0 /* address increment for one main loop pass */
412 jmp.l (2,%pc,%d1.l*4) /* switch ((dest_addr >> 2) & 3) */
413 bra.w .lines_lo2_start
414 bra.w .lines_lo6_start
415 bra.w .lines_lo10_start
416 /* bra.w .lines_lo14_start implicit */
417
418 /* word aligned destination (line + 14): use line bursts in the loop */
419.lines_lo14_start:
420 movem.l (%a0),%d4-%d7 /* load first line */
421 add.l %d0,%a0
422 swap %d4 /* swap words of 1st long */
423 move.w %d4,(%a1)+ /* store word */
424 jra .lines_lo14_entry /* jump into main loop */
425
426.lines_lo14_loop:
427 move.l %d4,%d0 /* move old line away */
428 move.l %d5,%d1
429 move.l %d6,%d2
430 move.l %d7,%d3
431 movem.l (%a0),%d4-%d7 /* load new line */
432 lea.l (16,%a0),%a0
433 swap %d4 /* swap words of 1st long */
434 move.w %d4,%d3 /* combine 1st high word with old low word */
435 movem.l %d0-%d3,(%a1) /* store line */
436 lea.l (16,%a1),%a1
437.lines_lo14_entry:
438 swap %d5 /* swap words of 2nd long */
439 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
440 swap %d6 /* swap words of 3rd long */
441 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
442 swap %d7 /* swap words of 4th long */
443 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
444 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
445 jhi .lines_lo14_loop
446
447 /* word aligned destination (line + 2/6/10/14): tail */
448.lines_lo14_end:
449 move.l %d4,(%a1)+ /* store third last longword */
450.lines_lo10_end:
451 move.l %d5,(%a1)+ /* store second last longword */
452.lines_lo6_end:
453 move.l %d6,(%a1)+ /* store last longword */
454.lines_lo2_end:
455 lea.l (12,%a2),%a2 /* readjust end address for doing longwords */
456 cmp.l %a0,%a2 /* any trailing longwords? */
457 jls .lines_do2_tail_end /* no: skip tail loop */
458
459.lines_do2_tail_loop:
460 move.l %d7,%d6 /* move old longword away */
461 move.l (%a0)+,%d7 /* load new longword */
462 swap %d7 /* swap words */
463 move.w %d7,%d6 /* combine high word with old low word */
464 move.l %d6,(%a1)+ /* store longword */
465 cmp.l %a0,%a2 /* runs %a0 up to last long bound */
466 jhi .lines_do2_tail_loop
467
468.lines_do2_tail_end:
469 swap %d7 /* undo swap */
470 move.w %d7,(%a1)+ /* store last word */
471 jra .lines_end
472
473 /* word aligned destination (line + 2): use line bursts in the loop */
474.lines_lo2_start:
475 movem.l (%a0),%d4-%d7 /* load first line */
476 add.l %d0,%a0
477 swap %d4 /* swap words of 1st long */
478 move.w %d4,(%a1)+ /* store high word */
479 swap %d5 /* swap words of 2nd long */
480 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
481 swap %d6 /* swap words of 3rd long */
482 move.w %d6,%d5 /* combine 3nd high word with 2nd low word */
483 swap %d7 /* swap words of 4th long */
484 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
485 move.l %d4,(%a1)+ /* store 1st longword */
486 move.l %d5,(%a1)+ /* store 2nd longword */
487 move.l %d6,(%a1)+ /* store 3rd longword */
488 cmp.l %a0,%a2 /* any full lines? */
489 jls .lines_lo2_end /* no: skip main loop */
490
491.lines_lo2_loop:
492 move.l %d7,%d3 /* move last longword of old line away */
493 movem.l (%a0),%d4-%d7 /* load line */
494 add.l %d0,%a0
495 swap %d4 /* swap words of 1st long */
496 move.w %d4,%d3 /* combine 1st high word with old low word */
497 swap %d5 /* swap words of 2nd long */
498 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
499 swap %d6 /* swap words of 3rd long */
500 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
501 swap %d7 /* swap words of 4th long */
502 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
503 movem.l %d3-%d6,(%a1) /* store line */
504 add.l %d0,%a1
505 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
506 jhi .lines_lo2_loop
507
508 jra .lines_lo2_end /* handle trailing longwords */
509
510 /* word aligned destination (line + 6): use line bursts in the loop */
511.lines_lo6_start:
512 movem.l (%a0),%d4-%d7 /* load first line */
513 add.l %d0,%a0
514 swap %d4 /* swap words of 1st long */
515 move.w %d4,(%a1)+ /* store high word */
516 swap %d5 /* swap words of 2nd long */
517 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
518 swap %d6 /* swap words of 3rd long */
519 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
520 move.l %d4,(%a1)+ /* store 1st longword */
521 move.l %d5,(%a1)+ /* store 2nd longword */
522 jra .lines_lo6_entry /* jump into main loop */
523
524.lines_lo6_loop:
525 move.l %d6,%d2 /* move last 2 longwords of old line away */
526 move.l %d7,%d3
527 movem.l (%a0),%d4-%d7 /* load line */
528 add.l %d0,%a0
529 swap %d4 /* swap words of 1st long */
530 move.w %d4,%d3 /* combine 1st high word with old low word */
531 swap %d5 /* swap words of 2nd long */
532 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
533 swap %d6 /* swap words of 3rd long */
534 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
535 movem.l %d2-%d5,(%a1) /* store line */
536 add.l %d0,%a1
537.lines_lo6_entry:
538 swap %d7 /* swap words of 4th long */
539 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
540 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
541 jhi .lines_lo6_loop
542
543 jra .lines_lo6_end /* handle trailing longwords */
544
545 /* word aligned destination (line + 10): use line bursts in the loop */
546.lines_lo10_start:
547 movem.l (%a0),%d4-%d7 /* load first line */
548 add.l %d0,%a0
549 swap %d4 /* swap words of 1st long */
550 move.w %d4,(%a1)+ /* store high word */
551 swap %d5 /* swap words of 2nd long */
552 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
553 move.l %d4,(%a1)+ /* store 1st longword */
554 jra .lines_lo10_entry /* jump into main loop */
555
556.lines_lo10_loop:
557 move.l %d5,%d1 /* move last 3 longwords of old line away */
558 move.l %d6,%d2
559 move.l %d7,%d3
560 movem.l (%a0),%d4-%d7 /* load line */
561 add.l %d0,%a0
562 swap %d4 /* swap words of 1st long */
563 move.w %d4,%d3 /* combine 1st high word with old low word */
564 swap %d5 /* swap words of 2nd long */
565 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
566 movem.l %d1-%d4,(%a1) /* store line */
567 add.l %d0,%a1
568.lines_lo10_entry:
569 swap %d6 /* swap words of 3rd long */
570 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
571 swap %d7 /* swap words of 4th long */
572 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
573 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
574 jhi .lines_lo10_loop
575
576 jra .lines_lo10_end /* handle trailing longwords */
577
578#else /* !FULLSPEED */
579
580 /* word aligned destination (long + 2): use line burst reads in the loop */
581.lines_do2_start:
582 cmp.l %a0,%d0 /* any leading longwords? */
583 jhi .lines_do2_head_start /* yes: leading longword copy */
584
585 movem.l (%a0),%d4-%d7 /* load first line */
586 lea.l (16,%a0),%a0
587 swap %d4 /* swap words of 1st long */
588 move.w %d4,(%a1)+ /* store high word */
589 jra .lines_do2_entry /* jump into main loop */
590
591.lines_do2_head_start:
592 move.l (%a0)+,%d7 /* load first longword */
593 swap %d7 /* swap words */
594 move.w %d7,(%a1)+ /* store high word */
595 cmp.l %a0,%d0 /* any full longword? */
596 jls .lines_do2_loop /* no: skip head loop */
597
598.lines_do2_head_loop:
599 move.l %d7,%d6 /* move old longword away */
600 move.l (%a0)+,%d7 /* load new longword */
601 swap %d7 /* swap words */
602 move.w %d7,%d6 /* combine high word with old low word */
603 move.l %d6,(%a1)+ /* store longword */
604 cmp.l %a0,%d0 /* runs %a0 up to first line bound */
605 jhi .lines_do2_head_loop
606
607.lines_do2_loop:
608 move.l %d7,%d3 /* move last longword of old line away */
609 movem.l (%a0),%d4-%d7 /* load line */
610 lea.l (16,%a0),%a0
611 swap %d4 /* swap words of 1st long */
612 move.w %d4,%d3 /* combine 1st high word with old low word */
613 move.l %d3,(%a1)+ /* store 1st longword */
614.lines_do2_entry:
615 swap %d5 /* swap words of 2nd long */
616 move.w %d5,%d4 /* combine 2nd high word with 1st low word */
617 move.l %d4,(%a1)+ /* store 2nd longword */
618 swap %d6 /* swap words of 3rd long */
619 move.w %d6,%d5 /* combine 3rd high word with 2nd low word */
620 move.l %d5,(%a1)+ /* store 3rd longword */
621 swap %d7 /* swap words of 4th long */
622 move.w %d7,%d6 /* combine 4th high word with 3rd low word */
623 move.l %d6,(%a1)+ /* store 4th longword */
624 cmp.l %a0,%a2 /* runs %a0 up to last line bound */
625 jhi .lines_do2_loop
626
627.lines_do2_end:
628 lea.l (12,%a2),%a2 /* readjust end address for doing longwords */
629 cmp.l %a0,%a2 /* any trailing longwords? */
630 jls .lines_do2_tail_end /* no: skip tail loop */
631
632.lines_do2_tail_loop:
633 move.l %d7,%d6 /* move old longword away */
634 move.l (%a0)+,%d7 /* load new longword */
635 swap %d7 /* swap words */
636 move.w %d7,%d6 /* combine high word with old low word */
637 move.l %d6,(%a1)+ /* store longword */
638 cmp.l %a0,%a2 /* runs %a0 up to last long bound */
639 jhi .lines_do2_tail_loop
640
641.lines_do2_tail_end:
642 swap %d7 /* undo swap */
643 move.w %d7,(%a1)+ /* store last word */
644 /* jra .lines_end implicit */
645
646#endif /* !FULLSPEED */
647
648.lines_end:
649 addq.l #3,%a2 /* readjust end address */
650 move.l %a2,%d1 /* end address in %d1 again */
651 movem.l (%sp),%d2-%d7/%a2 /* restore registers */
652 lea.l (28,%sp),%sp
653 jra .bytes2_start /* jump to trailing byte loop */
654
655.long_start:
656 subq.l #3,%d1 /* adjust end address for doing 4 bytes/ pass */
657
658 /* longword copy loop - no lines */
659.long_loop:
660 move.l (%a0)+,(%a1)+ /* copy longword (write can be unaligned) */
661 cmp.l %a0,%d1 /* runs %a0 up to last long bound */
662 jhi .long_loop
663
664 addq.l #3,%d1 /* readjust end address */
665 cmp.l %a0,%d1 /* any bytes left? */
666 jls .bytes2_end /* no: skip trailing byte loop */
667
668 /* trailing byte loop */
669.bytes2_loop:
670 move.b (%a0)+,(%a1)+ /* copy byte */
671.bytes2_start:
672 cmp.l %a0,%d1 /* runs %a0 up to end address */
673 jhi .bytes2_loop
674
675.bytes2_end:
676 move.l (4,%sp),%d0 /* return destination */
677 rts
678
679.end:
680 .size memcpy,.end-memcpy
diff --git a/firmware/target/coldfire/memmove-coldfire.S b/firmware/target/coldfire/memmove-coldfire.S
new file mode 100755
index 0000000000..bdd2e2e206
--- /dev/null
+++ b/firmware/target/coldfire/memmove-coldfire.S
@@ -0,0 +1,668 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21 .section .icode,"ax",@progbits
22
23#define FULLSPEED /* use burst writing for word aligned destinations */
24 .align 2
25 .global memmove
26 .type memmove,@function
27
28/* Moves <length> bytes of data in memory from <source> to <dest>
29 * Regions may overlap.
30 * This version is optimized for speed, and needs the corresponding memcpy
31 * implementation for the forward copy branch.
32 *
33 * arguments:
34 * (4,%sp) - destination address
35 * (8,%sp) - source address
36 * (12,%sp) - length
37 *
38 * return value:
39 * %d0 - destination address (like ANSI version)
40 *
41 * register usage:
42 * %a0 - current source address
43 * %a1 - current dest address
44 * %a2 - source start address (in line-copy loops)
45 * %d0 - source start address (byte and longword copy) / data / scratch
46 * %d1 - data / scratch
47 * %d2 - data / scratch
48 * %d3..%d7 - data
49 *
50 * For maximum speed this routine reads and writes whole lines using burst
51 * move (movem.l) where possible. For byte aligned destinations (long-1 and
52 * long-3) it writes longwords only. Same goes for word aligned destinations
53 * if FULLSPEED is undefined.
54 */
55memmove:
56 move.l (4,%sp),%a1 /* Destination */
57 move.l (8,%sp),%a0 /* Source */
58 move.l (12,%sp),%d1 /* Length */
59
60 cmp.l %a0,%a1
61 bhi.b .backward /* dest > src -> backward copy */
62 jmp __memcpy_fwd_entry
63
64.backward:
65 move.l %a0,%d0 /* %d0 = source start */
66 add.l %d1,%a0 /* %a0 = source end */
67 add.l %d1,%a1 /* %a1 = destination end */
68
69 move.l %a0,%d1
70 and.l #0xFFFFFFFC,%d1 /* %d1 = last source long bound */
71 subq.l #4,%d1
72 cmp.l %d0,%d1 /* at least one aligned longword to copy? */
73 blo.w .bytes2r_start
74
75 addq.l #4,%d1 /* %d1 = last source long bound */
76 cmp.l %d1,%a0 /* any bytes to copy */
77 jls .bytes1r_end /* no: skip byte loop */
78
79 /* leading byte loop: copies 0..3 bytes */
80.bytes1r_loop:
81 move.b -(%a0),-(%a1) /* copy byte */
82 cmp.l %d1,%a0 /* runs %a0 down to last long bound */
83 jhi .bytes1r_loop
84
85.bytes1r_end:
86 moveq.l #-16,%d1
87 add.l %a0,%d1
88 and.l #0xFFFFFFF0,%d1 /* %d1 = last source line bound - 16 */
89 cmp.l %d0,%d1 /* at least one aligned line to copy? */
90 blo.w .longr_start /* no: jump to longword copy loop */
91
92 lea.l (-28,%sp),%sp /* free up some registers */
93 movem.l %d2-%d7/%a2,(%sp)
94
95 moveq.l #16,%d2
96 add.l %d2,%d1 /* %d1 = last source line bound */
97 move.l %d0,%a2 /* %a2 = start address */
98 lea.l (15,%a2),%a2 /* adjust start address for loops doing 16 bytes/pass */
99 move.l %a1,%d0
100 moveq.l #3,%d2 /* mask */
101 and.l %d2,%d0
102 jmp.l (2,%pc,%d0.l*4) /* switch (dest_addr & 3) */
103 bra.w .lines_do0r_start
104 bra.w .lines_do1r_start
105 bra.w .lines_do2r_start
106 /* bra.w .lines_do3r_start implicit */
107
108 /* byte aligned destination (long - 1): use line burst reads in main loop */
109.lines_do3r_start:
110 moveq.l #24,%d0 /* shift count for shifting by 3 bytes */
111 cmp.l %d1,%a0 /* any leading longwords? */
112 jhi .lines_do3r_head_start /* yes: leading longword copy */
113
114 lea.l (-16,%a0),%a0
115 movem.l (%a0),%d3-%d6 /* load initial line */
116 move.l %d6,%d2 /* last longword, bytes 3210 */
117 move.b %d2,-(%a1) /* store byte */
118 lsr.l #8,%d2 /* last longword, bytes .321 */
119 move.w %d2,-(%a1) /* store word */
120 jra .lines_do3r_entry
121
122.lines_do3r_head_start:
123 move.l -(%a0),%d3 /* load initial longword */
124 move.l %d3,%d2 /* bytes 3210 */
125 move.b %d2,-(%a1) /* store byte */
126 lsr.l #8,%d2 /* bytes .321 */
127 move.w %d2,-(%a1) /* store word */
128 jra .lines_do3r_head_entry
129
130.lines_do3r_head_loop:
131 move.l %d3,%d4 /* move old longword away */
132 move.l -(%a0),%d3 /* load new longword */
133 move.l %d3,%d2
134 lsl.l #8,%d2 /* get bytes 210. */
135 or.l %d2,%d4 /* combine with old high byte */
136 move.l %d4,-(%a1) /* store longword */
137.lines_do3r_head_entry:
138 lsr.l %d0,%d3 /* shift down high byte */
139 cmp.l %d1,%a0 /* run %a0 down to last line bound */
140 jhi .lines_do3r_head_loop
141
142.lines_do3r_loop:
143 move.l %d3,%d7 /* move first longword of last line away */
144 lea.l (-16,%a0),%a0
145 movem.l (%a0),%d3-%d6 /* load new line */
146 move.l %d6,%d2
147 lsl.l #8,%d2 /* get bytes 210. of 4th longword */
148 or.l %d2,%d7 /* combine with high byte of old longword */
149 move.l %d7,-(%a1) /* store longword */
150.lines_do3r_entry:
151 lsr.l %d0,%d6 /* shift down high byte */
152 move.l %d5,%d2
153 lsl.l #8,%d2 /* get bytes 210. of 3rd longword */
154 or.l %d2,%d6 /* combine with high byte of 4th longword */
155 move.l %d6,-(%a1) /* store longword */
156 lsr.l %d0,%d5 /* shift down high byte */
157 move.l %d4,%d2
158 lsl.l #8,%d2 /* get bytes 210. of 2nd longword */
159 or.l %d2,%d5 /* combine with high byte or 3rd longword */
160 move.l %d5,-(%a1) /* store longword */
161 lsr.l %d0,%d4 /* shift down high byte */
162 move.l %d3,%d2
163 lsl.l #8,%d2 /* get bytes 210. of 1st longword */
164 or.l %d2,%d4 /* combine with high byte of 2nd longword */
165 move.l %d4,-(%a1) /* store longword */
166 lsr.l %d0,%d3 /* shift down high byte */
167 cmp.l %a2,%a0 /* run %a0 down to first line bound */
168 jhi .lines_do3r_loop
169
170 lea.l (-12,%a2),%a2 /* readjust start address for doing longwords */
171 cmp.l %a2,%a0 /* any trailing longwords? */
172 jls .lines_do3r_tail_end /* no: just store last high byte */
173
174.lines_do3r_tail_loop:
175 move.l %d3,%d4 /* move old longword away */
176 move.l -(%a0),%d3 /* load new longword */
177 move.l %d3,%d2
178 lsl.l #8,%d2 /* get bytes 210. */
179 or.l %d2,%d4 /* combine with old high byte */
180 move.l %d4,-(%a1) /* store longword */
181 lsr.l %d0,%d3 /* shift down high byte */
182 cmp.l %a2,%a0 /* run %a0 down to first long bound */
183 jhi .lines_do3r_tail_loop
184
185.lines_do3r_tail_end:
186 move.b %d3,-(%a1) /* store shifted-down high byte */
187 jra .linesr_end
188
189 /* byte aligned destination (long - 3): use line burst reads in main loop */
190.lines_do1r_start:
191 moveq.l #24,%d0 /* shift count for shifting by 3 bytes */
192 cmp.l %d1,%a0 /* any leading longwords? */
193 jhi .lines_do1r_head_start /* yes: leading longword copy */
194
195 lea.l (-16,%a0),%a0
196 movem.l (%a0),%d3-%d6 /* load initial line */
197 move.b %d6,-(%a1) /* store low byte of last longword */
198 jra .lines_do1r_entry
199
200.lines_do1r_head_start:
201 move.l -(%a0),%d3 /* load initial longword */
202 move.b %d3,-(%a1) /* store low byte */
203 jra .lines_do1r_head_entry
204
205.lines_do1r_head_loop:
206 move.l %d3,%d4 /* move old longword away */
207 move.l -(%a0),%d3 /* load new longword */
208 move.l %d3,%d2
209 lsl.l %d0,%d2 /* get low byte */
210 or.l %d2,%d4 /* combine with old bytes .321 */
211 move.l %d4,-(%a1) /* store longword */
212.lines_do1r_head_entry:
213 lsr.l #8,%d3 /* get bytes .321 */
214 cmp.l %d1,%a0 /* run %a0 down to last line bound */
215 jhi .lines_do1r_head_loop
216
217.lines_do1r_loop:
218 move.l %d3,%d7 /* move first longword of old line away */
219 lea.l (-16,%a0),%a0
220 movem.l (%a0),%d3-%d6 /* load new line */
221 move.l %d6,%d2
222 lsl.l %d0,%d2 /* get low byte of 4th longword */
223 or.l %d2,%d7 /* combine with bytes .321 of old longword */
224 move.l %d7,-(%a1) /* store longword */
225.lines_do1r_entry:
226 lsr.l #8,%d6 /* get bytes .321 */
227 move.l %d5,%d2
228 lsl.l %d0,%d2 /* get low byte of 3rd longword */
229 or.l %d2,%d6 /* combine with bytes .321 of 4th longword */
230 move.l %d6,-(%a1) /* store longword */
231 lsr.l #8,%d5 /* get bytes .321 */
232 move.l %d4,%d2
233 lsl.l %d0,%d2 /* get low byte of 2nd longword */
234 or.l %d2,%d5 /* combine with bytes .321 of 3rd longword */
235 move.l %d5,-(%a1) /* store longword */
236 lsr.l #8,%d4 /* get bytes .321 */
237 move.l %d3,%d2
238 lsl.l %d0,%d2 /* get low byte of 1st longword */
239 or.l %d2,%d4 /* combine with bytes .321 of 2nd longword */
240 move.l %d4,-(%a1) /* store longword */
241 lsr.l #8,%d3 /* get bytes .321 */
242 cmp.l %a2,%a0 /* run %a0 down to first line bound */
243 jhi .lines_do1r_loop
244
245 lea.l (-12,%a2),%a2 /* readjust start address for doing longwords */
246 cmp.l %a2,%a0 /* any trailing longwords? */
247 jls .lines_do1r_tail_end /* no: just store last high byte */
248
249.lines_do1r_tail_loop:
250 move.l %d3,%d4 /* move old longword away */
251 move.l -(%a0),%d3 /* load new longword */
252 move.l %d3,%d2
253 lsl.l %d0,%d2 /* get low byte */
254 or.l %d2,%d4 /* combine with old bytes .321 */
255 move.l %d4,-(%a1) /* store longword */
256 lsr.l #8,%d3 /* get bytes .321 */
257 cmp.l %a2,%a0 /* run %a0 down to first long bound */
258 jhi .lines_do1r_tail_loop
259
260.lines_do1r_tail_end:
261 move.w %d3,-(%a1) /* store word 21 */
262 swap %d3
263 move.b %d3,-(%a1) /* store byte 3 */
264 jra .linesr_end
265
266 /* long aligned destination (line - 0/4/8/12): head */
267.lines_do0r_head_loop:
268 move.l -(%a0),-(%a1) /* copy longword */
269.lines_do0r_start:
270 cmp.l %d1,%a0 /* run %a0 down to last line bound */
271 jhi .lines_do0r_head_loop
272
273.lines_do0r_head_end:
274 move.l %a1,%d1
275 lsr.l #2,%d1
276 moveq.l #3,%d0 /* mask */
277 and.l %d0,%d1
278 moveq.l #16,%d0 /* address decrement for one main loop pass */
279 jmp.l (2,%pc,%d1.l*2) /* switch ((dest_addr >> 2) & 3) */
280 bra.b .lines_lo0r_start
281 bra.b .lines_lo4r_start
282 bra.b .lines_lo8r_start
283 /* bra.b .lines_lo12r_start implicit */
284
285 /* long aligned destination (line - 4): use line bursts in the loop */
286.lines_lo12r_start:
287 sub.l %d0,%a0
288 movem.l (%a0),%d1-%d4 /* load initial line */
289 move.l %d4,-(%a1) /* store 4th longword */
290 move.l %d3,-(%a1) /* store 3rd longword */
291 move.l %d2,-(%a1) /* store 2nd longword */
292 cmp.l %a2,%a0 /* any full lines? */
293 jls .lines_lo12r_end /* no: skip main loop */
294
295.lines_lo12r_loop:
296 move.l %d1,%d5 /* move first longword of old line away */
297 sub.l %d0,%a0
298 movem.l (%a0),%d1-%d4 /* load new line */
299 sub.l %d0,%a1
300 movem.l %d2-%d5,(%a1) /* store line (1 old + 3 new longwords */
301 cmp.l %a2,%a0 /* run %a0 down to first line bound */
302 jhi .lines_lo12r_loop
303
304 jra .lines_lo12r_end /* handle trailing longwords */
305
306 /* line aligned destination: use line bursts in the loop */
307.lines_lo0r_start:
308.lines_lo0r_loop:
309 sub.l %d0,%a0
310 movem.l (%a0),%d1-%d4 /* load line */
311 sub.l %d0,%a1
312 movem.l %d1-%d4,(%a1) /* store line */
313 cmp.l %a2,%a0 /* run %a0 down to first line bound */
314 jhi .lines_lo0r_loop
315
316 jra .lines_lo0r_end /* handle trailing longwords */
317
318 /* long aligned destination (line - 8): use line bursts in the loop */
319.lines_lo8r_start:
320 sub.l %d0,%a0
321 movem.l (%a0),%d1-%d4 /* load initial line */
322 move.l %d4,-(%a1) /* store 4th longword */
323 move.l %d3,-(%a1) /* store 3rd longword */
324 cmp.l %a2,%a0 /* any full lines? */
325 jls .lines_lo8r_end /* no: skip main loop */
326
327.lines_lo8r_loop:
328 move.l %d2,%d6 /* move first 2 longwords of old line away */
329 move.l %d1,%d5
330 sub.l %d0,%a0
331 movem.l (%a0),%d1-%d4 /* load new line */
332 sub.l %d0,%a1
333 movem.l %d3-%d6,(%a1) /* store line (2 old + 2 new longwords */
334 cmp.l %a2,%a0 /* run %a0 down to first line bound */
335 jhi .lines_lo8r_loop
336
337 jra .lines_lo8r_end /* handle trailing longwords */
338
339 /* long aligned destination (line - 12): use line bursts in the loop */
340.lines_lo4r_start:
341 sub.l %d0,%a0
342 movem.l (%a0),%d1-%d4 /* load initial line */
343 move.l %d4,-(%a1) /* store 4th longword */
344 cmp.l %a2,%a0 /* any full lines? */
345 jls .lines_lo4r_end /* no: skip main loop */
346
347.lines_lo4r_loop:
348 move.l %d3,%d7 /* move first 3 longwords of old line away */
349 move.l %d2,%d6
350 move.l %d1,%d5
351 sub.l %d0,%a0
352 movem.l (%a0),%d1-%d4 /* load new line */
353 sub.l %d0,%a1
354 movem.l %d4-%d7,(%a1) /* store line (3 old + 1 new longwords */
355 cmp.l %a2,%a0 /* run %a0 down to first line bound */
356 jhi .lines_lo4r_loop
357
358 /* long aligned destination (line - 0/4/8/12): tail */
359.lines_lo4r_end:
360 move.l %d3,-(%a1) /* store 3rd last longword */
361.lines_lo8r_end:
362 move.l %d2,-(%a1) /* store 2nd last longword */
363.lines_lo12r_end:
364 move.l %d1,-(%a1) /* store last longword */
365.lines_lo0r_end:
366 lea.l (-12,%a2),%a2 /* readjust end address for doing longwords */
367 cmp.l %a2,%a0 /* any trailing longwords? */
368 jls .linesr_end /* no: get outta here */
369
370.lines_do0r_tail_loop:
371 move.l -(%a0),-(%a1) /* copy longword */
372 cmp.l %a2,%a0 /* run %a0 down to first long bound */
373 jhi .lines_do0r_tail_loop
374
375 jra .linesr_end
376
377#ifdef FULLSPEED
378 /* word aligned destination (line - 2/6/10/14): head */
379.lines_do2r_start:
380 cmp.l %d1,%a0 /* any leading longwords? */
381 jls .lines_do2r_selector /* no: jump to mainloop selector */
382
383 move.l -(%a0),%d3 /* load initial longword */
384 move.w %d3,-(%a1) /* store low word */
385 cmp.l %d1,%a0 /* any more longwords? */
386 jls .lines_do2r_head_end /* no: skip head loop */
387
388.lines_do2r_head_loop:
389 move.l %d3,%d4 /* move old longword away */
390 move.l -(%a0),%d3 /* load new longword */
391 move.w %d3,%d4 /* combine low word with old high word */
392 swap %d4 /* swap words */
393 move.l %d4,-(%a1) /* store longword */
394 cmp.l %d1,%a0 /* run %a0 down to last line bound */
395 jhi .lines_do2r_head_loop
396
397.lines_do2r_head_end:
398 swap %d3 /* get high word */
399 move.w %d3,-(%a1) /* and store it */
400
401.lines_do2r_selector:
402 move.l %a1,%d1
403 lsr.l #2,%d1
404 moveq.l #3,%d0 /* mask */
405 and.l %d0,%d1
406 moveq.l #16,%d7 /* address decrement for one main loop pass */
407 jmp.l (2,%pc,%d1.l*4) /* switch ((dest_addr >> 2) & 3) */
408 bra.w .lines_lo2r_start
409 bra.w .lines_lo6r_start
410 bra.w .lines_lo10r_start
411 /* bra.w .lines_lo14r_start implicit */
412
413 /* word aligned destination (line - 2): use line bursts in the loop */
414.lines_lo14r_start:
415 sub.l %d7,%a0
416 movem.l (%a0),%d0-%d3 /* load initial line */
417 move.w %d3,-(%a1) /* store last low word */
418 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
419 swap %d3 /* swap words of 3rd long */
420 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
421 swap %d2 /* swap words of 2nd long */
422 move.w %d0,%d1 /* combine 1st low word with 2nd high word */
423 swap %d1 /* swap words of 1st long */
424 move.l %d3,-(%a1) /* store 3rd longword */
425 move.l %d2,-(%a1) /* store 2nd longword */
426 move.l %d1,-(%a1) /* store 1st longword */
427 cmp.l %a2,%a0 /* any full lines? */
428 jls .lines_lo14r_end /* no: skip main loop */
429
430.lines_lo14r_loop:
431 move.l %d0,%d4 /* move first longword of old line away */
432 sub.l %d7,%a0
433 movem.l (%a0),%d0-%d3 /* load line */
434 move.w %d3,%d4 /* combine 4th low word with old high word */
435 swap %d4 /* swap words of 4th long */
436 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
437 swap %d3 /* swap words of 3rd long */
438 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
439 swap %d2 /* swap words of 2nd long */
440 move.w %d0,%d1 /* combine 1st low word with 2nd high word */
441 swap %d1 /* swap words of 1st long */
442 sub.l %d7,%a1
443 movem.l %d1-%d4,(%a1) /* store line */
444 cmp.l %a2,%a0 /* run %a0 down to first line bound */
445 jhi .lines_lo14r_loop
446
447 jra .lines_lo14r_end /* handle trailing longwords */
448
449 /* word aligned destination (line - 6): use line bursts in the loop */
450.lines_lo10r_start:
451 sub.l %d7,%a0
452 movem.l (%a0),%d0-%d3 /* load initial line */
453 move.w %d3,-(%a1) /* store last low word */
454 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
455 swap %d3 /* swap words of 3rd long */
456 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
457 swap %d2 /* swap words of 2nd long */
458 move.l %d3,-(%a1) /* store 3rd longword */
459 move.l %d2,-(%a1) /* store 2nd longword */
460 jra .lines_lo10r_entry /* jump into main loop */
461
462.lines_lo10r_loop:
463 move.l %d0,%d4 /* move first 2 longwords of old line away */
464 move.l %d1,%d5
465 sub.l %d7,%a0
466 movem.l (%a0),%d0-%d3 /* load line */
467 move.w %d3,%d4 /* combine 4th low word with old high word */
468 swap %d4 /* swap words of 4th long */
469 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
470 swap %d3 /* swap words of 3rd long */
471 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
472 swap %d2 /* swap words of 2nd long */
473 sub.l %d7,%a1
474 movem.l %d2-%d5,(%a1) /* store line */
475.lines_lo10r_entry:
476 move.w %d0,%d1 /* combine 1st low word with 2nd high word */
477 swap %d1 /* swap words of 1st long */
478 cmp.l %a2,%a0 /* run %a0 down to first line bound */
479 jhi .lines_lo10r_loop
480
481 jra .lines_lo10r_end /* handle trailing longwords */
482
483 /* word aligned destination (line - 10): use line bursts in the loop */
484.lines_lo6r_start:
485 sub.l %d7,%a0
486 movem.l (%a0),%d0-%d3 /* load initial line */
487 move.w %d3,-(%a1) /* store last low word */
488 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
489 swap %d3 /* swap words of 3rd long */
490 move.l %d3,-(%a1) /* store 3rd longword */
491 jra .lines_lo6r_entry /* jump into main loop */
492
493.lines_lo6r_loop:
494 move.l %d0,%d4 /* move first 3 longwords of old line away */
495 move.l %d1,%d5
496 move.l %d2,%d6
497 sub.l %d7,%a0
498 movem.l (%a0),%d0-%d3 /* load line */
499 move.w %d3,%d4 /* combine 4th low word with old high word */
500 swap %d4 /* swap words of 4th long */
501 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
502 swap %d3 /* swap words of 3rd long */
503 sub.l %d7,%a1
504 movem.l %d3-%d6,(%a1) /* store line */
505.lines_lo6r_entry:
506 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
507 swap %d2 /* swap words of 2nd long */
508 move.w %d0,%d1 /* combine 1st low word with 2nd high word */
509 swap %d1 /* swap words of 1st long */
510 cmp.l %a2,%a0 /* run %a0 down to first line bound */
511 jhi .lines_lo6r_loop
512
513 jra .lines_lo6r_end /* handle trailing longwords */
514
515 /* word aligned destination (line - 14): use line bursts in the loop */
516.lines_lo2r_start:
517 sub.l %d7,%a0
518 movem.l (%a0),%d0-%d3 /* load initial line */
519 move.w %d3,-(%a1) /* store last low word */
520 jra .lines_lo2r_entry /* jump into main loop */
521
522.lines_lo2r_loop:
523 move.l %d0,%d4 /* move old line away */
524 move.l %d1,%d5
525 move.l %d2,%d6
526 move.l %d3,%d7
527 lea.l (-16,%a0),%a0
528 movem.l (%a0),%d0-%d3 /* load line */
529 move.w %d3,%d4 /* combine 4th low word with old high word */
530 swap %d4 /* swap words of 4th long */
531 lea.l (-16,%a1),%a1
532 movem.l %d4-%d7,(%a1) /* store line */
533.lines_lo2r_entry:
534 move.w %d2,%d3 /* combine 3rd low word with 4th high word */
535 swap %d3 /* swap words of 3rd long */
536 move.w %d1,%d2 /* combine 2nd low word with 3rd high word */
537 swap %d2 /* swap words of 2nd long */
538 move.w %d0,%d1 /* combine 1st low word with 2nd high word */
539 swap %d1 /* swap words of 1st long */
540 cmp.l %a2,%a0 /* run %a0 down to first line bound */
541 jhi .lines_lo2r_loop
542
543 /* word aligned destination (line - 2/6/10/14): tail */
544.lines_lo2r_end:
545 move.l %d3,-(%a1) /* store third last longword */
546.lines_lo6r_end:
547 move.l %d2,-(%a1) /* store second last longword */
548.lines_lo10r_end:
549 move.l %d1,-(%a1) /* store last longword */
550.lines_lo14r_end:
551 lea.l (-12,%a2),%a2 /* readjust start address for doing longwords */
552 cmp.l %a2,%a0 /* any trailing longwords? */
553 jls .lines_do2r_tail_end /* no: skip tail loop */
554
555.lines_do2r_tail_loop:
556 move.l %d0,%d1 /* move old longword away */
557 move.l -(%a0),%d0 /* load new longword */
558 move.w %d0,%d1 /* combine low word with old high word */
559 swap %d1 /* swap words */
560 move.l %d1,-(%a1) /* store longword */
561 cmp.l %a2,%a0 /* run %a0 down to first long bound */
562 jhi .lines_do2r_tail_loop
563
564.lines_do2r_tail_end:
565 swap %d0 /* get final high word */
566 move.w %d0,-(%a1) /* store it */
567 /* jra .linesr_end implicit */
568
569#else /* !FULLSPEED */
570
571 /* word aligned destination (long - 2): use line burst reads in the loop */
572.lines_do2r_start:
573 cmp.l %d1,%a0 /* any leading longwords? */
574 jhi .lines_do2r_head_start /* yes: leading longword copy */
575
576 lea.l (-16,%a0),%a0
577 movem.l (%a0),%d3-%d6 /* load initial line */
578 move.w %d6,-(%a1) /* store last low word */
579 jra .lines_do2r_entry /* jump into main loop */
580
581.lines_do2r_head_start:
582 move.l -(%a0),%d3 /* load initial longword */
583 move.w %d3,-(%a1) /* store low word */
584 cmp.l %d1,%a0 /* any full longword? */
585 jls .lines_do2r_loop /* no: skip head loop */
586
587.lines_do2r_head_loop:
588 move.l %d3,%d4 /* move old longword away */
589 move.l -(%a0),%d3 /* load new longword */
590 move.w %d3,%d4 /* combine low word with old high word */
591 swap %d4 /* swap words */
592 move.l %d4,-(%a1) /* store longword */
593 cmp.l %d1,%a0 /* run %a0 down to last line bound */
594 jhi .lines_do2r_head_loop
595
596.lines_do2r_loop:
597 move.l %d3,%d7 /* move first longword of old line away */
598 lea.l (-16,%a0),%a0
599 movem.l (%a0),%d3-%d6 /* load line */
600 move.w %d6,%d7 /* combine 4th low word with old high word */
601 swap %d7 /* swap words of 4th long */
602 move.l %d7,-(%a1) /* store 4th longword */
603.lines_do2r_entry:
604 move.w %d5,%d6 /* combine 3rd low word with 4th high word */
605 swap %d6 /* swap words of 3rd long */
606 move.l %d6,-(%a1) /* store 3rd longword */
607 move.w %d4,%d5 /* combine 2nd low word with 3rd high word */
608 swap %d5 /* swap words of 2nd long */
609 move.l %d5,-(%a1) /* store 2nd longword */
610 move.w %d3,%d4 /* combine 1st low word with 2nd high word */
611 swap %d4 /* swap words of 1st long */
612 move.l %d4,-(%a1) /* store 1st longword */
613 cmp.l %a2,%a0 /* run %a0 down to first line bound */
614 jhi .lines_do2r_loop
615
616.lines_do2r_end:
617 lea.l (-12,%a2),%a2 /* readjust start address for doing longwords */
618 cmp.l %a2,%a0 /* any trailing longwords? */
619 jls .lines_do2r_tail_end /* no: skip tail loop */
620
621.lines_do2r_tail_loop:
622 move.l %d3,%d4 /* move old longword away */
623 move.l -(%a0),%d3 /* load new longword */
624 move.w %d3,%d4 /* combine low word with old high word */
625 swap %d4 /* swap words */
626 move.l %d4,-(%a1) /* store longword */
627 cmp.l %a2,%a0 /* run %a0 down to first long bound */
628 jhi .lines_do2r_tail_loop
629
630.lines_do2r_tail_end:
631 swap %d3 /* get final high word */
632 move.w %d3,-(%a1) /* store it */
633 /* jra .linesr_end implicit */
634
635#endif /* !FULLSPEED */
636
637.linesr_end:
638 subq.l #3,%a2 /* readjust end address */
639 move.l %a2,%d0 /* start address in %d0 again */
640 movem.l (%sp),%d2-%d7/%a2 /* restore registers */
641 lea.l (28,%sp),%sp
642 jra .bytes2r_start /* jump to trailing byte loop */
643
644.longr_start:
645 addq.l #3,%d0 /* adjust start address for doing 4 bytes/ pass */
646
647 /* longword copy loop - no lines */
648.longr_loop:
649 move.l -(%a0),-(%a1) /* copy longword (write can be unaligned) */
650 cmp.l %d0,%a0 /* runs %a0 down to first long bound */
651 jhi .longr_loop
652
653 subq.l #3,%d0 /* readjust start address */
654 cmp.l %d0,%a0 /* any bytes left? */
655 jls .bytes2r_end /* no: skip trailing byte loop */
656
657 /* trailing byte loop */
658.bytes2r_loop:
659 move.b -(%a0),-(%a1) /* copy byte */
660.bytes2r_start:
661 cmp.l %d0,%a0 /* runs %a0 down to start address */
662 jhi .bytes2r_loop
663
664.bytes2r_end:
665 rts /* returns start address */
666
667.end:
668 .size memmove,.end-memmove
diff --git a/firmware/target/coldfire/memset-coldfire.S b/firmware/target/coldfire/memset-coldfire.S
new file mode 100755
index 0000000000..7c9fe88463
--- /dev/null
+++ b/firmware/target/coldfire/memset-coldfire.S
@@ -0,0 +1,150 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21 .section .icode,"ax",@progbits
22
23 .align 2
24 .global memset
25 .type memset,@function
26
27/* Fills a memory region with specified byte value
28 * This version is optimized for speed
29 *
30 * arguments:
31 * (4,%sp) - start address
32 * (8,%sp) - data
33 * (12,%sp) - length
34 *
35 * return value:
36 * %d0 - start address (like ANSI version)
37 *
38 * register usage:
39 * %d0 - data (spread to all 4 bytes when using long stores)
40 * %d1 - temporary / data (for burst transfer)
41 * %d2 - data (for burst transfer)
42 * %d3 - data (for burst transfer)
43 * %a0 - start address
44 * %a1 - current address (runs down from end to start)
45 *
46 * For maximum speed this routine uses both long stores and burst mode,
47 * storing whole lines with movem.l. The routine fills memory from end
48 * to start in order to ease returning the start address.
49 */
50memset:
51 move.l (4,%sp),%a0 /* start address */
52 move.l (8,%sp),%d0 /* data */
53 move.l (12,%sp),%a1 /* length */
54 add.l %a0,%a1 /* %a1 = end address */
55
56 move.l %a0,%d1
57 addq.l #7,%d1
58 and.l #0xFFFFFFFC,%d1 /* %d1 = first long bound + 4 */
59 cmp.l %d1,%a1 /* at least one aligned longword to fill? */
60 blo.b .no_longs /* no, jump directly to byte loop */
61
62 and.l #0xFF,%d0 /* start: spread data to all 4 bytes */
63 move.l %d0,%d1
64 lsl.l #8,%d1
65 or.l %d1,%d0 /* data now in 2 lower bytes of %d0 */
66 move.l %d0,%d1
67 swap %d0
68 or.l %d1,%d0 /* data now in all 4 bytes of %d0 */
69
70 move.l %a1,%d1
71 and.l #0xFFFFFFFC,%d1 /* %d1 = last long bound */
72 cmp.l %d1,%a1 /* any bytes to set? */
73 bls.b .end_b1 /* no: skip byte loop */
74
75 /* leading byte loop: sets 0..3 bytes */
76.loop_b1:
77 move.b %d0,-(%a1) /* store byte */
78 cmp.l %d1,%a1 /* runs %a1 down to last long bound */
79 bhi.b .loop_b1
80
81.end_b1:
82 moveq.l #31,%d1
83 add.l %a0,%d1
84 and.l #0xFFFFFFF0,%d1 /* %d1 = first line bound + 16 */
85 cmp.l %d1,%a1 /* at least one full line to fill? */
86 blo.b .no_lines /* no, jump to longword loop */
87
88 mov.l %a1,%d1
89 and.l #0xFFFFFFF0,%d1 /* %d1 = last line bound */
90 cmp.l %d1,%a1 /* any longwords to set? */
91 bls.b .end_l1 /* no: skip longword loop */
92
93 /* leading longword loop: sets 0..3 longwords */
94.loop_l1:
95 move.l %d0,-(%a1) /* store longword */
96 cmp.l %d1,%a1 /* runs %a1 down to last line bound */
97 bhi.b .loop_l1
98
99.end_l1:
100 move.l %d2,-(%sp) /* free some registers */
101 move.l %d3,-(%sp)
102
103 move.l %d0,%d1 /* spread data to 4 data registers */
104 move.l %d0,%d2
105 move.l %d0,%d3
106 lea.l (15,%a0),%a0 /* start address += 15, acct. for trl. data */
107
108 /* main loop: set whole lines utilising burst mode */
109.loop_line:
110 lea.l (-16,%a1),%a1 /* pre-decrement */
111 movem.l %d0-%d3,(%a1) /* store line */
112 cmp.l %a0,%a1 /* runs %a1 down to first line bound */
113 bhi.b .loop_line
114
115 lea.l (-15,%a0),%a0 /* correct start address */
116 move.l (%sp)+,%d3 /* restore registers */
117 move.l (%sp)+,%d2
118
119 move.l %a0,%d1 /* %d1 = start address ... */
120 addq.l #3,%d1 /* ... +3, account for possible trailing bytes */
121 cmp.l %d1,%a1 /* any longwords left */
122 bhi.b .loop_l2 /* yes: jump to longword loop */
123 bra.b .no_longs /* no: skip loop */
124
125.no_lines:
126 move.l %a0,%d1 /* %d1 = start address ... */
127 addq.l #3,%d1 /* ... +3, account for possible trailing bytes */
128
129 /* trailing longword loop */
130.loop_l2:
131 move.l %d0,-(%a1) /* store longword */
132 cmp.l %d1,%a1 /* runs %a1 down to first long bound */
133 bhi.b .loop_l2
134
135.no_longs:
136 cmp.l %a0,%a1 /* any bytes left? */
137 bls.b .end_b2 /* no: skip loop */
138
139 /* trailing byte loop */
140.loop_b2:
141 move.b %d0,-(%a1) /* store byte */
142 cmp.l %a0,%a1 /* runs %a1 down to start address */
143 bhi.b .loop_b2
144
145.end_b2:
146 move.l %a0,%d0 /* return start address */
147 rts
148
149.end:
150 .size memset,.end-memset
diff --git a/firmware/target/coldfire/memset16-coldfire.S b/firmware/target/coldfire/memset16-coldfire.S
new file mode 100755
index 0000000000..d9f72f683f
--- /dev/null
+++ b/firmware/target/coldfire/memset16-coldfire.S
@@ -0,0 +1,144 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21 .section .icode,"ax",@progbits
22
23 .global memset16
24 .type memset16,@function
25
26/* Fills a memory region with specified word value
27 * Start address must be word aligned, length is in words
28 * This version is optimized for speed
29 *
30 * arguments:
31 * (4,%sp) - start address
32 * (8,%sp) - data
33 * (12,%sp) - length
34 *
35 * return value:
36 * %d0 - start address
37 *
38 * register usage:
39 * %d0 - data (spread to both words when using long stores)
40 * %d1 - temporary / data (for burst transfer)
41 * %d2 - data (for burst transfer)
42 * %d3 - data (for burst transfer)
43 * %a0 - start address
44 * %a1 - current address (runs down from end to start)
45 *
46 * For maximum speed this routine uses both long stores and burst mode,
47 * storing whole lines with movem.l. The routine fills memory from end
48 * to start in order to ease returning the start address.
49 */
50memset16:
51 move.l (4,%sp),%a0 /* start address */
52 move.l (8,%sp),%d0 /* data */
53 move.l (12,%sp),%a1 /* length */
54 add.l %a1,%a1
55 add.l %a0,%a1 /* %a1 = end address */
56
57 move.l %a0,%d1
58 addq.l #6,%d1
59 and.l #0xFFFFFFFC,%d1 /* %d1 = first long bound + 4 */
60 cmp.l %d1,%a1 /* at least one aligned longword to fill? */
61 blo.b .no_longs /* no, jump directly to word loop */
62
63 and.l #0xFFFF,%d0 /* start: spread data to both words */
64 move.l %d0,%d1
65 swap %d1
66 or.l %d1,%d0 /* data now in both words */
67
68 move.l %a1,%d1
69 and.l #0xFFFFFFFC,%d1 /* %d1 = last long bound */
70 cmp.l %d1,%a1 /* one extra word? */
71 bls.b .end_w1 /* no: skip */
72
73 move.w %d0,-(%a1) /* set leading word */
74
75.end_w1:
76 moveq.l #30,%d1
77 add.l %a0,%d1
78 and.l #0xFFFFFFF0,%d1 /* %d1 = first line bound + 16 */
79 cmp.l %d1,%a1 /* at least one full line to fill? */
80 blo.b .no_lines /* no, jump to longword loop */
81
82 mov.l %a1,%d1
83 and.l #0xFFFFFFF0,%d1 /* %d1 = last line bound */
84 cmp.l %d1,%a1 /* any longwords to set? */
85 bls.b .end_l1 /* no: skip longword loop */
86
87 /* leading longword loop: sets 0..3 longwords */
88.loop_l1:
89 move.l %d0,-(%a1) /* store longword */
90 cmp.l %d1,%a1 /* runs %a1 down to last line bound */
91 bhi.b .loop_l1
92
93.end_l1:
94 move.l %d2,-(%sp) /* free some registers */
95 move.l %d3,-(%sp)
96
97 move.l %d0,%d1 /* spread data to 4 data registers */
98 move.l %d0,%d2
99 move.l %d0,%d3
100 lea.l (14,%a0),%a0 /* start address += 14, acct. for trl. data */
101
102 /* main loop: set whole lines utilising burst mode */
103.loop_line:
104 lea.l (-16,%a1),%a1 /* pre-decrement */
105 movem.l %d0-%d3,(%a1) /* store line */
106 cmp.l %a0,%a1 /* runs %a1 down to first line bound */
107 bhi.b .loop_line
108
109 lea.l (-14,%a0),%a0 /* correct start address */
110 move.l (%sp)+,%d3 /* restore registers */
111 move.l (%sp)+,%d2
112
113 move.l %a0,%d1 /* %d1 = start address ... */
114 addq.l #2,%d1 /* ... +2, account for possible trailing word */
115 cmp.l %d1,%a1 /* any longwords left */
116 bhi.b .loop_l2 /* yes: jump to longword loop */
117 bra.b .no_longs /* no: skip loop */
118
119.no_lines:
120 move.l %a0,%d1 /* %d1 = start address ... */
121 addq.l #2,%d1 /* ... +2, account for possible trailing word */
122
123 /* trailing longword loop */
124.loop_l2:
125 move.l %d0,-(%a1) /* store longword */
126 cmp.l %d1,%a1 /* runs %a1 down to first long bound */
127 bhi.b .loop_l2
128
129.no_longs:
130 cmp.l %a0,%a1 /* any words left? */
131 bls.b .end_w2 /* no: skip loop */
132
133 /* trailing word loop */
134.loop_w2:
135 move.w %d0,-(%a1) /* store word */
136 cmp.l %a0,%a1 /* runs %a1 down to start address */
137 bhi.b .loop_w2
138
139.end_w2:
140 move.l %a0,%d0 /* return start address */
141 rts
142
143.end:
144 .size memset16,.end-memset16