summaryrefslogtreecommitdiff
path: root/libc/string/csky/cskyv1/strcpy.S
diff options
context:
space:
mode:
authorGuo Ren <ren_guo@c-sky.com>2017-10-15 20:59:34 +0800
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2017-11-19 09:20:11 +0100
commit2fcffe26e815b7125a357c83b59617ab93c16b41 (patch)
treefe5a973dc4bbf38bce8468a4497f5f656f082a9f /libc/string/csky/cskyv1/strcpy.S
parent9e38e0aa45cca21d5023d0af94377f0e1e41d2f4 (diff)
csky: port to uclibc-ng
Follow the steps to build c-sky uclibc linux system: 1. git clone https://github.com/c-sky/buildroot.git 2. cd buildroot 3. make qemu_csky_ck810_uclibc_defconfig 4. make Follow the buildroot/board/qemu/csky/readme.txt to run. This buildroot toolchain is pre-build, But you can rebuild the c-sky uclibc-ng alone and install it to the buildroot sysroot manually. We'll try our best to improve the uclibc-ng continuously. Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Diffstat (limited to 'libc/string/csky/cskyv1/strcpy.S')
-rw-r--r--libc/string/csky/cskyv1/strcpy.S139
1 files changed, 139 insertions, 0 deletions
diff --git a/libc/string/csky/cskyv1/strcpy.S b/libc/string/csky/cskyv1/strcpy.S
new file mode 100644
index 000000000..c2f1e7a0f
--- /dev/null
+++ b/libc/string/csky/cskyv1/strcpy.S
@@ -0,0 +1,139 @@
+#include <features.h>
+#include <endian.h>
+
+#ifdef WANT_WIDE
+# define Wstrcpy wcscpy
+#else
+# define Wstrcpy strcpy
+#endif
+
+ .align 2
+ .global Wstrcpy
+ .type Wstrcpy, @function
+Wstrcpy:
+
+ mov r6, r2
+ mov r7, r3
+ or r7, r6
+ andi r7, 3
+ cmpnei r7, 0
+ bf 2f
+ 1:
+ ldb r5, (r3)
+ stb r5, (r6)
+ addi r3, 1
+ addi r6, 1
+ cmpnei r5, 0
+ bt 1b
+ 1:
+ jmp r15
+
+ 2:
+ ldw r5, (r3)
+ tstnbz r5
+ bf 10f
+ stw r5, (r6)
+
+ ldw r5, (r3, 4)
+ tstnbz r5
+ bf 3f
+ stw r5, (r6, 4)
+
+ ldw r5, (r3, 8)
+ tstnbz r5
+ bf 4f
+ stw r5, (r6, 8)
+
+ ldw r5, (r3, 12)
+ tstnbz r5
+ bf 5f
+ stw r5, (r6, 12)
+
+ ldw r5, (r3, 16)
+ tstnbz r5
+ bf 6f
+ stw r5, (r6, 16)
+
+ ldw r5, (r3, 20)
+ tstnbz r5
+ bf 7f
+ stw r5, (r6, 20)
+
+ ldw r5, (r3, 24)
+ tstnbz r5
+ bf 8f
+ stw r5, (r6, 24)
+
+ ldw r5, (r3, 28)
+ tstnbz r5
+ bf 9f
+ stw r5, (r6, 28)
+
+ addi r6, 32
+ addi r3, 32
+ br 2b
+
+ 3:
+ addi r6, 4
+ br 10f
+
+ 4:
+ addi r6, 8
+ br 10f
+
+ 5:
+ addi r6, 12
+ br 10f
+
+ 6:
+ addi r6, 16
+ br 10f
+
+ 7:
+ addi r6, 20
+ br 10f
+
+ 8:
+ addi r6, 24
+ br 10f
+
+ 9:
+ addi r6, 28
+
+ 10:
+#ifdef __CSKYBE__
+ xtrb0 r1, r5
+ stb r1, (r6)
+ cmpnei r1, 0
+ bf 5f
+ xtrb1 r1, r5
+ stb r1, (r6, 1)
+ cmpnei r1, 0
+ bf 5f
+ xtrb2 r1, r5
+ stb r1, (r6, 2 )
+ cmpnei r1, 0
+ bf 5f
+ stw r5, (r6)
+
+#else
+ xtrb3 r1, r5
+ stb r1, (r6)
+ cmpnei r1, 0
+ bf 5f
+ xtrb2 r1, r5
+ stb r1, (r6, 1)
+ cmpnei r1, 0
+ bf 5f
+ xtrb1 r1, r5
+ stb r1, (r6, 2)
+ cmpnei r1, 0
+ bf 5f
+ stw r5, (r6)
+#endif
+ 5:
+ jmp r15
+
+
+libc_hidden_def(Wstrcpy)
+.weak Wstrcpy