strcpy.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Cloned and hacked for uClibc by Paul Mundt, December 2003 */
  3. /* Modified by SuperH, Inc. September 2003 */
  4. ! Entry: arg0: destination
  5. ! arg1: source
  6. ! Exit: result: destination
  7. !
  8. ! SH5 code Copyright 2002 SuperH Ltd.
  9. #if __BYTE_ORDER == __LITTLE_ENDIAN
  10. #define SHHI shlld
  11. #define SHLO shlrd
  12. #else
  13. #define SHHI shlrd
  14. #define SHLO shlld
  15. #endif
  16. .section .text..SHmedia32,"ax"
  17. .globl strcpy
  18. .type strcpy, @function
  19. .align 5
  20. strcpy:
  21. pta/l shortstring,tr1
  22. ldlo.q r3,0,r4
  23. ptabs r18,tr4
  24. shlli r3,3,r7
  25. addi r2, 8, r0
  26. mcmpeq.b r4,r63,r6
  27. SHHI r6,r7,r6
  28. bnei/u r6,0,tr1 // shortstring
  29. pta/l no_lddst, tr2
  30. ori r3,-8,r23
  31. sub r2, r23, r0
  32. sub r3, r2, r21
  33. addi r21, 8, r20
  34. ldx.q r0, r21, r5
  35. pta/l loop, tr0
  36. ori r2,-8,r22
  37. mcmpeq.b r5, r63, r6
  38. bgt/u r22, r23, tr2 // no_lddst
  39. // r22 < r23 : Need to do a load from the destination.
  40. // r22 == r23 : Doesn't actually need to load from destination,
  41. // but still can be handled here.
  42. ldlo.q r2, 0, r9
  43. movi -1, r8
  44. SHLO r8, r7, r8
  45. mcmv r4, r8, r9
  46. stlo.q r2, 0, r9
  47. beqi/l r6, 0, tr0 // loop
  48. add r5, r63, r4
  49. addi r0, 8, r0
  50. blink tr1, r63 // shortstring
  51. no_lddst:
  52. // r22 > r23: note that for r22 == r23 the sthi.q would clobber
  53. // bytes before the destination region.
  54. stlo.q r2, 0, r4
  55. SHHI r4, r7, r4
  56. sthi.q r0, -1, r4
  57. beqi/l r6, 0, tr0 // loop
  58. add r5, r63, r4
  59. addi r0, 8, r0
  60. shortstring:
  61. #if __BYTE_ORDER != __LITTLE_ENDIAN
  62. pta/l shortstring2,tr1
  63. byterev r4,r4
  64. #endif
  65. shortstring2:
  66. st.b r0,-8,r4
  67. andi r4,0xff,r5
  68. shlri r4,8,r4
  69. addi r0,1,r0
  70. bnei/l r5,0,tr1
  71. blink tr4,r63 // return
  72. .balign 8
  73. loop:
  74. stlo.q r0, 0, r5
  75. ldx.q r0, r20, r4
  76. addi r0, 16, r0
  77. sthi.q r0, -9, r5
  78. mcmpeq.b r4, r63, r6
  79. bnei/u r6, 0, tr1 // shortstring
  80. ldx.q r0, r21, r5
  81. stlo.q r0, -8, r4
  82. sthi.q r0, -1, r4
  83. mcmpeq.b r5, r63, r6
  84. beqi/l r6, 0, tr0 // loop
  85. add r5, r63, r4
  86. addi r0, 8, r0
  87. blink tr1, r63 // shortstring
  88. .size strcpy,.-strcpy