1 /* Copyright (C) 1999-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
20 /* void *memcpy(void *dst, const void *src, size_t n);
21 No overlap between the memory of DST and of SRC are assumed. */
24 mov r4,r3 /* Save destination. */
26 /* If less than 11 bytes, just do a byte copy. */
31 /* Check if we need to word-align source. */
36 mov.b @r0+,r1 /* Copy one byte. */
43 /* Check if we need to longword-align source. */
47 mov.w @r0+,r1 /* Copy one word. */
65 /* Calculate the correct routine to handle the destination
66 alignment and simultaneously calculate the loop counts for
67 both the 2 word copy loop and byte copy loop. */
84 .word L_copydest0 - L_base
85 .word L_copydest1_or_3 - L_base
86 .word L_copydest2 - L_base
87 .word L_copydest1_or_3 - L_base
90 /* Copy routine for (dest mod 4) == 1 or == 3. */
94 L_copydest1_or_3_loop:
95 mov.l @r5+,r0 /* Read first longword. */
97 mov.l @r5+,r1 /* Read second longword. */
99 /* Write first longword as byte, word, byte. */
106 /* Write second longword as byte, word, byte. */
113 /* Write first longword as byte, word, byte. */
120 /* Write second longword as byte, word, byte. */
127 bf/s L_copydest1_or_3_loop
134 /* Copy routine for (dest mod 4) == 2. */
140 #ifdef __BIG_ENDIAN__
157 bf/s L_copydest2_loop
164 /* Copy routine for (dest mod 4) == 0. */
174 bf/s L_copydest0_loop
177 add #8,r4 /* Fall through. */
184 /* Copy remaining bytes. */
194 mov r3,r0 /* Return destination. */
196 libc_hidden_builtin_def (memcpy)