1
/* $Id: memcpy.S,v 1.3 2001/07/27 11:50:52 gniibe Exp $
3
* "memcpy" implementation of SuperH
5
* Copyright (C) 1999 Niibe Yutaka
10
* void *memcpy(void *dst, const void *src, size_t n);
11
* No overlap between the memory of DST and of SRC are assumed.
14
#include <linux/linkage.h>
17
bt/s 9f ! if n=0, do nothing
19
sub r4,r5 ! From here, r5 has the distance to r0
20
add r6,r0 ! From here, r0 points the end of copying point
23
bt/s 7f ! if it's too small, copy a byte at once
26
! From here, r6 is free
28
! r4 --> [ ... ] DST [ ... ] SRC
31
! r0 --> [ ... ] r0+r5 --> [ ... ]
38
mov r0,r3 ! Save the value on R0 to R3
43
mov r3,r0 ! and back to R0
57
bt/s 8b ! while (r0>r2)
65
! GHIJ KLMN OPQR --> GHIJ KLMN OPQR
67
! First, align to long word boundary
80
2: ! Second, copy a long word at once
88
! Third, copy a byte at once, if necessary
97
! GHIJ KLMN OPQR --> ...G HIJK LMNO PQR.
99
! First, align to long word boundary
110
2: ! Second, read a long word and write a long word at once
116
#ifdef __LITTLE_ENDIAN__
120
mov.l @(r0,r5),r1 ! NMLK
131
mov.l @(r0,r5),r1 ! KLMN
140
! Third, copy a byte at once, if necessary
149
! GHIJ KLMN OPQR --> ..GH IJKL MNOP QR..
151
! First, align to word boundary
158
2: ! Second, read a word and write a word at once
168
! Third, copy a byte at once, if necessary
178
! GHIJ KLMN OPQR --> .GHI JKLM NOPQ R...
180
! First, align to long word boundary
191
2: ! Second, read a long word and write a long word at once
198
#ifdef __LITTLE_ENDIAN__
201
mov.l @(r0,r5),r1 ! NMLK
212
mov.l @(r0,r5),r1 ! KLMN
222
! Third, copy a byte at once, if necessary