xref: /openbmc/linux/arch/csky/abiv2/strcpy.S (revision 35267cea)
1/* SPDX-License-Identifier: GPL-2.0 */
2// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3
4#include <linux/linkage.h>
5#include "sysdep.h"
6
7ENTRY(strcpy)
8	mov	a3, a0
9	/* Check if the src addr is aligned.  */
10        andi    t0, a1, 3
11        bnez	t0, 11f
121:
13	/* Check if all the bytes in the word are not zero.  */
14	ldw	a2, (a1)
15	tstnbz	a2
16	bf	9f
17	stw	a2, (a3)
18
19	ldw	a2, (a1, 4)
20	tstnbz	a2
21	bf	2f
22	stw	a2, (a3, 4)
23
24	ldw	a2, (a1, 8)
25	tstnbz	a2
26	bf	3f
27	stw	a2, (a3, 8)
28
29	ldw	a2, (a1, 12)
30	tstnbz	a2
31	bf	4f
32	stw	a2, (a3, 12)
33
34	ldw	a2, (a1, 16)
35	tstnbz	a2
36	bf	5f
37	stw	a2, (a3, 16)
38
39	ldw	a2, (a1, 20)
40	tstnbz	a2
41	bf	6f
42	stw	a2, (a3, 20)
43
44	ldw	a2, (a1, 24)
45	tstnbz	a2
46	bf	7f
47	stw	a2, (a3, 24)
48
49	ldw	a2, (a1, 28)
50	tstnbz	a2
51	bf	8f
52	stw	a2, (a3, 28)
53
54	addi	a3, 32
55	addi	a1, 32
56	br	1b
57
58
592:
60	addi	a3, 4
61	br	9f
62
633:
64	addi	a3, 8
65	br	9f
66
674:
68	addi	a3, 12
69	br	9f
70
715:
72	addi	a3, 16
73	br	9f
74
756:
76	addi	a3, 20
77	br	9f
78
797:
80	addi	a3, 24
81	br	9f
82
838:
84	addi	a3, 28
859:
86# ifdef __CSKYBE__
87	xtrb0	t0, a2
88	st.b	t0, (a3)
89	bez	t0, 10f
90	xtrb1	t0, a2
91	st.b	t0, (a3, 1)
92	bez	t0, 10f
93	xtrb2	t0, a2
94	st.b	t0, (a3, 2)
95	bez	t0, 10f
96	stw	a2, (a3)
97# else
98	xtrb3	t0, a2
99	st.b	t0, (a3)
100	bez	t0, 10f
101	xtrb2	t0, a2
102	st.b	t0, (a3, 1)
103	bez	t0, 10f
104	xtrb1	t0, a2
105	st.b	t0, (a3, 2)
106	bez	t0, 10f
107	stw	a2, (a3)
108# endif	/* !__CSKYBE__ */
10910:
110	jmp	lr
111
11211:
113	subi    t0, 4
11412:
115        ld.b    a2, (a1)
116        st.b	a2, (a3)
117        bez	a2, 10b
118	addi    t0, 1
119        addi    a1, a1, 1
120        addi    a3, a3, 1
121	bnez	t0, 12b
122	jbr	1b
123ENDPROC(strcpy)
124