abiv2_strcpy.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
  5. * in this tarball.
  6. */
  7. #include <endian.h>
  8. #include "macro.S"
  9. #ifdef WANT_WIDE
  10. # define Wstrcpy wcscpy
  11. #else
  12. # define Wstrcpy strcpy
  13. #endif
  14. .align 2
  15. .global Wstrcpy
  16. .type Wstrcpy, @function
  17. Wstrcpy:
  18. mov a3, a0
  19. or a2, a1, a3
  20. andi t0, a2, 3
  21. M_BEZ t0, 2f
  22. mov t0, a1
  23. 1:
  24. ld.b a2, (t0)
  25. stb a2, (a3)
  26. addi t0, t0, 1
  27. addi a3, a3, 1
  28. M_BNEZ a2, 1b
  29. jmp r15
  30. 2:
  31. ldw a2, (a1)
  32. tstnbz a2
  33. bf 11f
  34. stw a2, (a3)
  35. ldw a2, (a1, 4)
  36. tstnbz a2
  37. bf 4f
  38. stw a2, (a3, 4)
  39. ldw a2, (a1, 8)
  40. tstnbz a2
  41. bf 5f
  42. stw a2, (a3, 8)
  43. ldw a2, (a1, 12)
  44. tstnbz a2
  45. bf 6f
  46. stw a2, (a3, 12)
  47. ldw a2, (a1, 16)
  48. tstnbz a2
  49. bf 7f
  50. stw a2, (a3, 16)
  51. ldw a2, (a1, 20)
  52. tstnbz a2
  53. bf 8f
  54. stw a2, (a3, 20)
  55. ldw a2, (a1, 24)
  56. tstnbz a2
  57. bf 9f
  58. stw a2, (a3, 24)
  59. ldw a2, (a1, 28)
  60. tstnbz a2
  61. bf 10f
  62. stw a2, (a3, 28)
  63. addi a3, 32
  64. addi a1, 32
  65. br 2b
  66. 4:
  67. addi a3, 4
  68. br 11f
  69. 5:
  70. addi a3, 8
  71. br 11f
  72. 6:
  73. addi a3, 12
  74. br 11f
  75. 7:
  76. addi a3, 16
  77. br 11f
  78. 8:
  79. addi a3, 20
  80. br 11f
  81. 9:
  82. addi a3, 24
  83. br 11f
  84. 10:
  85. addi a3, 28
  86. 11:
  87. #ifdef __CSKYBE__
  88. xtrb0 t0, a2
  89. st.b t0, (a3)
  90. M_BEZ t0, 5f
  91. xtrb1 t0, a2
  92. st.b t0, (a3, 1)
  93. M_BEZ t0, 5f
  94. xtrb2 t0, a2
  95. st.b t0, (a3, 2 )
  96. M_BEZ t0, 5f
  97. stw a2, (a3)
  98. #else
  99. xtrb3 t0, a2
  100. st.b t0, (a3)
  101. M_BEZ t0, 5f
  102. xtrb2 t0, a2
  103. st.b t0, (a3, 1)
  104. M_BEZ t0, 5f
  105. xtrb1 t0, a2
  106. st.b t0, (a3, 2)
  107. M_BEZ t0, 5f
  108. stw a2, (a3)
  109. #endif
  110. 5:
  111. jmp r15
  112. libc_hidden_def(Wstrcpy)
  113. .weak Wstrcpy