1 /* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4 Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 /* void *memcpy(void *dst, const void *src, size_t n);
25 No overlap between the memory of DST and of SRC are assumed. */
28 mov r4,r3 /* Save destination. */
30 /* If less than 11 bytes, just do a byte copy. */
35 /* Check if we need to word-align source. */
40 mov.b @r0+,r1 /* Copy one byte. */
47 /* Check if we need to longword-align source. */
51 mov.w @r0+,r1 /* Copy one word. */
53 #if __BYTE_ORDER == __BIG_ENDIAN
69 /* Calculate the correct routine to handle the destination
70 alignment and simultaneously calculate the loop counts for
71 both the 2 word copy loop and byte copy loop. */
88 .word L_copydest0 - L_base
89 .word L_copydest1_or_3 - L_base
90 .word L_copydest2 - L_base
91 .word L_copydest1_or_3 - L_base
94 /* Copy routine for (dest mod 4) == 1 or == 3. */
98 L_copydest1_or_3_loop:
99 mov.l @r5+,r0 /* Read first longword. */
101 mov.l @r5+,r1 /* Read second longword. */
102 #if __BYTE_ORDER == __BIG_ENDIAN
103 /* Write first longword as byte, word, byte. */
110 /* Write second longword as byte, word, byte. */
117 /* Write first longword as byte, word, byte. */
124 /* Write second longword as byte, word, byte. */
131 bf/s L_copydest1_or_3_loop
138 /* Copy routine for (dest mod 4) == 2. */
144 #if __BYTE_ORDER == __BIG_ENDIAN
161 bf/s L_copydest2_loop
168 /* Copy routine for (dest mod 4) == 0. */
178 bf/s L_copydest0_loop
181 add #8,r4 /* Fall through. */
188 /* Copy remaining bytes. */
198 mov r3,r0 /* Return destination. */
200 libc_hidden_builtin_def (memcpy)