1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* $Id: memcpy.S,v 1.3 2001/07/27 11:50:52 gniibe Exp $
4 * "memcpy" implementation of SuperH
6 * Copyright (C) 1999 Niibe Yutaka
11 * void *memcpy(void *dst, const void *src, size_t n);
12 * No overlap between the memory of DST and of SRC are assumed.
15 #include <linux/linkage.h>
18 bt/s 9f ! if n=0, do nothing
20 sub r4,r5 ! From here, r5 has the distance to r0
21 add r6,r0 ! From here, r0 points the end of copying point
24 bt/s 7f ! if it's too small, copy a byte at once
27 ! From here, r6 is free
29 ! r4 --> [ ... ] DST [ ... ] SRC
32 ! r0 --> [ ... ] r0+r5 --> [ ... ]
39 mov r0,r3 ! Save the value on R0 to R3
44 mov r3,r0 ! and back to R0
58 bt/s 8b ! while (r0>r2)
66 ! GHIJ KLMN OPQR --> GHIJ KLMN OPQR
68 ! First, align to long word boundary
81 2: ! Second, copy a long word at once
89 ! Third, copy a byte at once, if necessary
98 ! GHIJ KLMN OPQR --> ...G HIJK LMNO PQR.
100 ! First, align to long word boundary
111 2: ! Second, read a long word and write a long word at once
117 #ifdef __LITTLE_ENDIAN__
121 mov.l @(r0,r5),r1 ! NMLK
132 mov.l @(r0,r5),r1 ! KLMN
141 ! Third, copy a byte at once, if necessary
150 ! GHIJ KLMN OPQR --> ..GH IJKL MNOP QR..
152 ! First, align to word boundary
159 2: ! Second, read a word and write a word at once
169 ! Third, copy a byte at once, if necessary
179 ! GHIJ KLMN OPQR --> .GHI JKLM NOPQ R...
181 ! First, align to long word boundary
192 2: ! Second, read a long word and write a long word at once
199 #ifdef __LITTLE_ENDIAN__
202 mov.l @(r0,r5),r1 ! NMLK
213 mov.l @(r0,r5),r1 ! KLMN
223 ! Third, copy a byte at once, if necessary