1/* The assembly function for string copy. C-SKY ABIV2 version. 2 Copyright (C) 2018-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library. If not, see 17 <https://www.gnu.org/licenses/>. */ 18 19#include <sysdep.h> 20 21ENTRY (strcpy) 22 mov a3, a0 23 /* Check if the src addr is aligned. */ 24 andi t0, a1, 3 25 bnez t0, 11f 261: 27 /* Check if all the bytes in the word are not zero. */ 28 ldw a2, (a1) 29 tstnbz a2 30 bf 9f 31 stw a2, (a3) 32 33 ldw a2, (a1, 4) 34 tstnbz a2 35 bf 2f 36 stw a2, (a3, 4) 37 38 ldw a2, (a1, 8) 39 tstnbz a2 40 bf 3f 41 stw a2, (a3, 8) 42 43 ldw a2, (a1, 12) 44 tstnbz a2 45 bf 4f 46 stw a2, (a3, 12) 47 48 ldw a2, (a1, 16) 49 tstnbz a2 50 bf 5f 51 stw a2, (a3, 16) 52 53 ldw a2, (a1, 20) 54 tstnbz a2 55 bf 6f 56 stw a2, (a3, 20) 57 58 ldw a2, (a1, 24) 59 tstnbz a2 60 bf 7f 61 stw a2, (a3, 24) 62 63 ldw a2, (a1, 28) 64 tstnbz a2 65 bf 8f 66 stw a2, (a3, 28) 67 68 addi a3, 32 69 addi a1, 32 70 br 1b 71 722: 73 addi a3, 4 74 br 9f 75 763: 77 addi a3, 8 78 br 9f 79 804: 81 addi a3, 12 82 br 9f 83 845: 85 addi a3, 16 86 br 9f 87 886: 89 addi a3, 20 90 br 9f 91 927: 93 addi a3, 24 94 br 9f 95 968: 97 addi a3, 28 989: 99 xtrb3 t0, a2 100 st.b t0, (a3) 101 bez t0, 10f 102 xtrb2 t0, a2 103 st.b t0, (a3, 1) 104 bez t0, 10f 105 xtrb1 t0, a2 106 st.b t0, (a3, 2) 107 bez t0, 10f 108 stw a2, (a3) 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 br 1b 123 124END (strcpy) 125 126libc_hidden_def (strcpy) 127.weak strcpy 128