1 /* Copyright (C) 1999-2014 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, see
18 <http://www.gnu.org/licenses/>. */
22 /* void *memcpy(void *dst, const void *src, size_t n);
23 No overlap between the memory of DST and of SRC are assumed. */
26 mov r4,r3 /* Save destination. */
28 /* If less than 11 bytes, just do a byte copy. */
33 /* Check if we need to word-align source. */
38 mov.b @r0+,r1 /* Copy one byte. */
45 /* Check if we need to longword-align source. */
49 mov.w @r0+,r1 /* Copy one word. */
67 /* Calculate the correct routine to handle the destination
68 alignment and simultaneously calculate the loop counts for
69 both the 2 word copy loop and byte copy loop. */
86 .word L_copydest0 - L_base
87 .word L_copydest1_or_3 - L_base
88 .word L_copydest2 - L_base
89 .word L_copydest1_or_3 - L_base
92 /* Copy routine for (dest mod 4) == 1 or == 3. */
96 L_copydest1_or_3_loop:
97 mov.l @r5+,r0 /* Read first longword. */
99 mov.l @r5+,r1 /* Read second longword. */
100 #ifdef __BIG_ENDIAN__
101 /* Write first longword as byte, word, byte. */
108 /* Write second longword as byte, word, byte. */
115 /* Write first longword as byte, word, byte. */
122 /* Write second longword as byte, word, byte. */
129 bf/s L_copydest1_or_3_loop
136 /* Copy routine for (dest mod 4) == 2. */
142 #ifdef __BIG_ENDIAN__
159 bf/s L_copydest2_loop
166 /* Copy routine for (dest mod 4) == 0. */
176 bf/s L_copydest0_loop
179 add #8,r4 /* Fall through. */
186 /* Copy remaining bytes. */
196 mov r3,r0 /* Return destination. */
198 libc_hidden_builtin_def (memcpy)