strcpy.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 <features.h>
  8. #include <endian.h>
  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 r6, r2
  19. mov r7, r3
  20. or r7, r6
  21. andi r7, 3
  22. cmpnei r7, 0
  23. bf 2f
  24. 1:
  25. ldb r5, (r3)
  26. stb r5, (r6)
  27. addi r3, 1
  28. addi r6, 1
  29. cmpnei r5, 0
  30. bt 1b
  31. 1:
  32. jmp r15
  33. 2:
  34. ldw r5, (r3)
  35. tstnbz r5
  36. bf 10f
  37. stw r5, (r6)
  38. ldw r5, (r3, 4)
  39. tstnbz r5
  40. bf 3f
  41. stw r5, (r6, 4)
  42. ldw r5, (r3, 8)
  43. tstnbz r5
  44. bf 4f
  45. stw r5, (r6, 8)
  46. ldw r5, (r3, 12)
  47. tstnbz r5
  48. bf 5f
  49. stw r5, (r6, 12)
  50. ldw r5, (r3, 16)
  51. tstnbz r5
  52. bf 6f
  53. stw r5, (r6, 16)
  54. ldw r5, (r3, 20)
  55. tstnbz r5
  56. bf 7f
  57. stw r5, (r6, 20)
  58. ldw r5, (r3, 24)
  59. tstnbz r5
  60. bf 8f
  61. stw r5, (r6, 24)
  62. ldw r5, (r3, 28)
  63. tstnbz r5
  64. bf 9f
  65. stw r5, (r6, 28)
  66. addi r6, 32
  67. addi r3, 32
  68. br 2b
  69. 3:
  70. addi r6, 4
  71. br 10f
  72. 4:
  73. addi r6, 8
  74. br 10f
  75. 5:
  76. addi r6, 12
  77. br 10f
  78. 6:
  79. addi r6, 16
  80. br 10f
  81. 7:
  82. addi r6, 20
  83. br 10f
  84. 8:
  85. addi r6, 24
  86. br 10f
  87. 9:
  88. addi r6, 28
  89. 10:
  90. #ifdef __CSKYBE__
  91. xtrb0 r1, r5
  92. stb r1, (r6)
  93. cmpnei r1, 0
  94. bf 5f
  95. xtrb1 r1, r5
  96. stb r1, (r6, 1)
  97. cmpnei r1, 0
  98. bf 5f
  99. xtrb2 r1, r5
  100. stb r1, (r6, 2 )
  101. cmpnei r1, 0
  102. bf 5f
  103. stw r5, (r6)
  104. #else
  105. xtrb3 r1, r5
  106. stb r1, (r6)
  107. cmpnei r1, 0
  108. bf 5f
  109. xtrb2 r1, r5
  110. stb r1, (r6, 1)
  111. cmpnei r1, 0
  112. bf 5f
  113. xtrb1 r1, r5
  114. stb r1, (r6, 2)
  115. cmpnei r1, 0
  116. bf 5f
  117. stw r5, (r6)
  118. #endif
  119. 5:
  120. jmp r15
  121. libc_hidden_def(Wstrcpy)
  122. .weak Wstrcpy