memset-sparc.s 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. TEXT memset(SB),$0
  2. /*
  3. * performance:
  4. * (tba)
  5. */
  6. MOVW R7, 0(FP)
  7. MOVW n+8(FP), R9 /* R9 is count */
  8. MOVW p+0(FP), R10 /* R10 is pointer */
  9. MOVW c+4(FP), R11 /* R11 is char */
  10. ADD R9,R10, R12 /* R12 is end pointer */
  11. /*
  12. * if not at least 4 chars,
  13. * dont even mess around.
  14. * 3 chars to guarantee any
  15. * rounding up to a word
  16. * boundary and 4 characters
  17. * to get at least maybe one
  18. * full word store.
  19. */
  20. SUBCC $4,R9, R0
  21. BL out
  22. /*
  23. * turn R11 into a word of characters
  24. */
  25. AND $0xff, R11
  26. SLL $8,R11, R7
  27. OR R7, R11
  28. SLL $16,R11, R7
  29. OR R7, R11
  30. /*
  31. * store one byte at a time until pointer
  32. * is alligned on a word boundary
  33. */
  34. l1:
  35. ANDCC $3,R10, R0
  36. BE l2
  37. MOVB R11, 0(R10)
  38. ADD $1, R10
  39. JMP l1
  40. /*
  41. * turn R9 into end pointer-15
  42. * store 16 at a time while theres room
  43. */
  44. l2:
  45. ADD $-15,R12, R9
  46. SUBCC R10,R9, R0
  47. BLEU l4
  48. l3:
  49. MOVW R11, 0(R10)
  50. MOVW R11, 4(R10)
  51. ADD $16, R10
  52. SUBCC R10,R9, R0
  53. MOVW R11, -8(R10)
  54. MOVW R11, -4(R10)
  55. BGU l3
  56. /*
  57. * turn R9 into end pointer-3
  58. * store 4 at a time while theres room
  59. */
  60. l4:
  61. ADD $-3,R12, R9
  62. l5:
  63. SUBCC R10,R9, R0
  64. BLEU out
  65. MOVW R11, 0(R10)
  66. ADD $4, R10
  67. JMP l5
  68. /*
  69. * last loop, store byte at a time
  70. */
  71. out:
  72. SUBCC R10,R12, R0
  73. BLEU ret
  74. MOVB R11, 0(R10)
  75. ADD $1, R10
  76. JMP out
  77. ret:
  78. MOVW s1+0(FP), R7
  79. RETURN