strcpy.S 1.9 KB

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