summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/memmove-coldfire.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/memmove-coldfire.S')
-rwxr-xr-xfirmware/target/coldfire/memmove-coldfire.S668
1 files changed, 668 insertions, 0 deletions
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