summaryrefslogtreecommitdiff
path: root/libc/string/csky/cskyv1/strcpy.S
blob: c2f1e7a0f1eb0f9b1f67ad461de23f6e9e6225a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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