memset.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* Set a block of memory to some byte value.
  2. For SPARC v7.
  3. Copyright (C) 1996, 1999, 2003 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by David S. Miller <davem@caip.rutgers.edu> and
  6. Jakub Jelinek <jj@ultra.linux.cz>.
  7. The GNU C Library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11. The GNU C Library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with the GNU C Library; if not, write to the Free
  17. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18. 02111-1307 USA. */
  19. /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
  20. #define ZERO_BIG_BLOCK(base, offset, source) \
  21. std source, [base + offset + 0x00]; \
  22. std source, [base + offset + 0x08]; \
  23. std source, [base + offset + 0x10]; \
  24. std source, [base + offset + 0x18]; \
  25. std source, [base + offset + 0x20]; \
  26. std source, [base + offset + 0x28]; \
  27. std source, [base + offset + 0x30]; \
  28. std source, [base + offset + 0x38];
  29. #define ZERO_LAST_BLOCKS(base, offset, source) \
  30. std source, [base - offset - 0x38]; \
  31. std source, [base - offset - 0x30]; \
  32. std source, [base - offset - 0x28]; \
  33. std source, [base - offset - 0x20]; \
  34. std source, [base - offset - 0x18]; \
  35. std source, [base - offset - 0x10]; \
  36. std source, [base - offset - 0x08]; \
  37. std source, [base - offset - 0x00];
  38. .text
  39. .align 4
  40. ENTRY(__bzero)
  41. b 1f
  42. mov %g0, %g3
  43. 3: cmp %o2, 3
  44. be 2f
  45. stb %g3, [%o0]
  46. cmp %o2, 2
  47. be 2f
  48. stb %g3, [%o0 + 0x01]
  49. stb %g3, [%o0 + 0x02]
  50. 2: sub %o2, 4, %o2
  51. add %o1, %o2, %o1
  52. b 4f
  53. sub %o0, %o2, %o0
  54. END(__bzero)
  55. strong_alias(__bzero,bzero)
  56. ENTRY(__memset)
  57. and %o1, 0xff, %g3
  58. sll %g3, 8, %g2
  59. or %g3, %g2, %g3
  60. sll %g3, 16, %g2
  61. or %g3, %g2, %g3
  62. orcc %o2, %g0, %o1
  63. 1: cmp %o1, 7
  64. bleu 7f
  65. mov %o0, %g1
  66. andcc %o0, 3, %o2
  67. bne 3b
  68. 4: andcc %o0, 4, %g0
  69. be 2f
  70. mov %g3, %g2
  71. st %g3, [%o0]
  72. sub %o1, 4, %o1
  73. add %o0, 4, %o0
  74. 2: andcc %o1, 0xffffff80, %o3
  75. be 9f
  76. andcc %o1, 0x78, %o2
  77. 4: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
  78. subcc %o3, 128, %o3
  79. ZERO_BIG_BLOCK (%o0, 0x40, %g2)
  80. bne 4b
  81. add %o0, 128, %o0
  82. orcc %o2, %g0, %g0
  83. 9: be 6f
  84. andcc %o1, 7, %o1
  85. mov %o7, %g4
  86. 101: call 100f
  87. srl %o2, 1, %o3
  88. mov %g4, %o7
  89. jmpl %o4 + (20f + 64 - 101b), %g0
  90. add %o0, %o2, %o0
  91. 100: retl
  92. sub %o7, %o3, %o4
  93. 20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
  94. ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
  95. 6: be 8f
  96. andcc %o1, 4, %g0
  97. be 1f
  98. andcc %o1, 2, %g0
  99. st %g3, [%o0]
  100. add %o0, 4, %o0
  101. 1: be 1f
  102. andcc %o1, 1, %g0
  103. sth %g3, [%o0]
  104. add %o0, 2, %o0
  105. 1: bne,a 8f
  106. stb %g3, [%o0]
  107. 8: retl
  108. mov %g1, %o0
  109. 7: orcc %o1, 0, %g0
  110. be 0f
  111. subcc %o1, 1, %o1
  112. stb %g3, [%o0]
  113. be 0f
  114. subcc %o1, 1, %o1
  115. stb %g3, [%o0 + 1]
  116. be 0f
  117. subcc %o1, 1, %o1
  118. stb %g3, [%o0 + 2]
  119. be 0f
  120. subcc %o1, 1, %o1
  121. stb %g3, [%o0 + 3]
  122. be 0f
  123. subcc %o1, 1, %o1
  124. stb %g3, [%o0 + 4]
  125. be 0f
  126. subcc %o1, 1, %o1
  127. stb %g3, [%o0 + 5]
  128. be 0f
  129. subcc %o1, 1, %o1
  130. stb %g3, [%o0 + 6]
  131. 0: retl
  132. nop
  133. END(__memset)
  134. strong_alias(__memset,memset)