fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / machine / xscale / strcpy.c
blob46db2ba6ab05059672529a7173faa7743a4057bb
1 #if defined __thumb__
3 #include "../../string/strcpy.c"
5 #else
7 #include <string.h>
8 #include "xscale.h"
10 char *
11 strcpy (char *dest, const char *src)
13 char *dest0 = dest;
15 asm (PRELOADSTR ("%0") : : "r" (src));
17 #ifndef __OPTIMIZE_SIZE__
18 if (((long)src & 3) == ((long)dest & 3))
20 /* Skip unaligned part. */
21 while ((long)src & 3)
23 if (! (*dest++ = *src++))
24 return dest0;
27 /* Load two constants:
28 R4 = 0xfefefeff [ == ~(0x80808080 << 1) ]
29 R5 = 0x80808080 */
31 asm ("mov r5, #0x80\n\
32 ldr r1, [%1, #0]\n\
33 add r5, r5, #0x8000\n\
34 add r5, r5, r5, lsl #16\n\
35 mvn r4, r5, lsl #1\n\
36 \n\
37 add r3, r1, r5\n\
38 bic r3, r3, r1\n\
39 ands r2, r3, r4\n\
40 bne 1f\n\
41 0:\n\
42 ldr r3, [%1, #0]\n\
43 ldr r1, [%1, #4]!\n\
44 " PRELOADSTR("%1") "\n\
45 str r3, [%0], #4\n\
46 add r2, r1, r4\n\
47 bic r2, r2, r1\n\
48 ands r3, r2, r5\n\
49 beq 0b\n\
50 1:"
51 : "=&r" (dest), "=&r" (src)
52 : "0" (dest), "1" (src)
53 : "r1", "r2", "r3", "r4", "r5", "memory", "cc");
55 #endif
57 while (*dest++ = *src++)
58 asm (PRELOADSTR ("%0") : : "r" (src));
59 return dest0;
62 #endif