strcpy.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ! Copyright (C) 2013 Imagination Technologies Ltd.
  2. ! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  3. .text
  4. .global _strcpy
  5. .type _strcpy,function
  6. ! D1Ar1 dst
  7. ! D0Ar2 src
  8. _strcpy:
  9. MOV A1.2, D1Ar1
  10. ! test 4 byte alignment of src
  11. ANDS D0Ar4, D0Ar2, #3
  12. BNZ $Lbyteloop
  13. ! test 4 byte alignment of dest
  14. ANDS D1Ar5, D1Ar1, #3
  15. BNZ $Lbyteloop
  16. ! load mask values for aligned loops
  17. MOVT D1Ar3, #HI(0xfefefeff)
  18. ADD D1Ar3, D1Ar3, #LO(0xfefefeff)
  19. MOVT D0FrT, #HI(0x80808080)
  20. ADD D0FrT, D0FrT, #LO(0x80808080)
  21. ! test 8 byte alignment of src
  22. ANDS D0Ar4, D0Ar2, #7
  23. BNZ $Lwordloop
  24. ! test 8 byte alignment of dest
  25. ANDS D1Ar5, D1Ar1, #7
  26. BNZ $Lwordloop
  27. $L8byteloop:
  28. GETL D1Ar5, D0Ar6, [D0Ar2++]
  29. MOV D1Re0, D1Ar5
  30. MOV D0Re0, D1Ar5
  31. ADD D1Re0, D1Re0, D1Ar3
  32. XOR D0Re0, D0Re0, #-1
  33. AND D1Re0, D1Re0, D0Re0
  34. ANDS D1Re0, D1Re0, D0FrT
  35. BNZ $Lnullfound ! NULL in first word
  36. MOV D1Re0, D0Ar6
  37. MOV D0Re0, D0Ar6
  38. ADD D1Re0, D1Re0, D1Ar3
  39. XOR D0Re0, D0Re0, #-1
  40. AND D1Re0, D1Re0, D0Re0
  41. ANDS D1Re0, D1Re0, D0FrT
  42. BNZ $Lnullfound2 ! NULL in the second word
  43. SETL [A1.2++], D1Ar5, D0Ar6
  44. B $L8byteloop
  45. $Lwordloop:
  46. GETD D0Ar6, [D0Ar2++]
  47. MOV D1Re0, D0Ar6
  48. MOV D0Re0, D0Ar6
  49. ADD D1Re0, D1Re0, D1Ar3
  50. XOR D0Re0, D0Re0, #-1
  51. AND D1Re0, D1Re0, D0Re0
  52. ANDS D1Re0, D1Re0, D0FrT
  53. MOV D1Ar5, D0Ar6
  54. BNZ $Lnullfound
  55. SETD [A1.2++], D0Ar6
  56. B $Lwordloop
  57. $Lnullfound2:
  58. SETD [A1.2++], D1Ar5
  59. MOV D1Ar5, D0Ar6
  60. $Lnullfound:
  61. SETB [A1.2++], D1Ar5
  62. ANDS D0Ar6, D1Ar5, #0xff
  63. LSR D1Ar5, D1Ar5, #8
  64. BNZ $Lnullfound
  65. B $Lend
  66. $Lbyteloop:
  67. GETB D0Ar6, [D0Ar2++]
  68. SETB [A1.2++], D0Ar6
  69. CMP D0Ar6, #0
  70. BNZ $Lbyteloop
  71. $Lend:
  72. MOV D0Re0, D1Ar1
  73. MOV PC, D1RtP
  74. .size _strcpy,.-_strcpy
  75. libc_hidden_def(strcpy)