1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* $Id: memmove.S,v 1.2 2001/07/27 11:51:09 gniibe Exp $
4 * "memmove" implementation of SuperH
6 * Copyright (C) 1999 Niibe Yutaka
11 * void *memmove(void *dst, const void *src, size_t n);
12 * The memory areas may overlap.
15 #include <linux/linkage.h>
17 ! if dest > src, call memcpy (it copies in decreasing order)
26 sub r5,r4 ! From here, r4 has the distance to r0
28 bt/s 9f ! if n=0, do nothing
33 bt/s 8f ! if it's too small, copy a byte at once
37 ! [ ... ] DST [ ... ] SRC
40 ! r0+r4--> [ ... ] r0 --> [ ... ]
49 mov r0,r3 ! Save the value on R0 to R3
54 mov r3,r0 ! and back to R0
65 bf/s 8b ! while (r0<r5)
79 ! GHIJ KLMN OPQR --> GHIJ KLMN OPQR
81 ! First, align to long word boundary
94 2: ! Second, copy a long word at once
103 ! Third, copy a byte at once, if necessary
112 ! GHIJ KLMN OPQR --> ...G HIJK LMNO PQR.
114 ! First, align to long word boundary
127 2: ! Second, read a long word and write a long word at once
133 #ifdef __LITTLE_ENDIAN__
160 ! Third, copy a byte at once, if necessary
170 ! GHIJ KLMN OPQR --> ..GH IJKL MNOP QR..
172 ! First, align to word boundary
179 2: ! Second, read a word and write a word at once
189 ! Third, copy a byte at once, if necessary
200 ! GHIJ KLMN OPQR --> .GHI JKLM NOPQ R...
202 ! First, align to long word boundary
215 2: ! Second, read a long word and write a long word at once
220 #ifdef __LITTLE_ENDIAN__
244 bf/s 3b ! while(r0<r5)
249 ! Third, copy a byte at once, if necessary