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. ENTRY(memset)
  56. and %o1, 0xff, %g3
  57. sll %g3, 8, %g2
  58. or %g3, %g2, %g3
  59. sll %g3, 16, %g2
  60. or %g3, %g2, %g3
  61. orcc %o2, %g0, %o1
  62. 1: cmp %o1, 7
  63. bleu 7f
  64. mov %o0, %g1
  65. andcc %o0, 3, %o2
  66. bne 3b
  67. 4: andcc %o0, 4, %g0
  68. be 2f
  69. mov %g3, %g2
  70. st %g3, [%o0]
  71. sub %o1, 4, %o1
  72. add %o0, 4, %o0
  73. 2: andcc %o1, 0xffffff80, %o3
  74. be 9f
  75. andcc %o1, 0x78, %o2
  76. 4: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
  77. subcc %o3, 128, %o3
  78. ZERO_BIG_BLOCK (%o0, 0x40, %g2)
  79. bne 4b
  80. add %o0, 128, %o0
  81. orcc %o2, %g0, %g0
  82. 9: be 6f
  83. andcc %o1, 7, %o1
  84. mov %o7, %g4
  85. 101: call 100f
  86. srl %o2, 1, %o3
  87. mov %g4, %o7
  88. jmpl %o4 + (20f + 64 - 101b), %g0
  89. add %o0, %o2, %o0
  90. 100: retl
  91. sub %o7, %o3, %o4
  92. 20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
  93. ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
  94. 6: be 8f
  95. andcc %o1, 4, %g0
  96. be 1f
  97. andcc %o1, 2, %g0
  98. st %g3, [%o0]
  99. add %o0, 4, %o0
  100. 1: be 1f
  101. andcc %o1, 1, %g0
  102. sth %g3, [%o0]
  103. add %o0, 2, %o0
  104. 1: bne,a 8f
  105. stb %g3, [%o0]
  106. 8: retl
  107. mov %g1, %o0
  108. 7: orcc %o1, 0, %g0
  109. be 0f
  110. subcc %o1, 1, %o1
  111. stb %g3, [%o0]
  112. be 0f
  113. subcc %o1, 1, %o1
  114. stb %g3, [%o0 + 1]
  115. be 0f
  116. subcc %o1, 1, %o1
  117. stb %g3, [%o0 + 2]
  118. be 0f
  119. subcc %o1, 1, %o1
  120. stb %g3, [%o0 + 3]
  121. be 0f
  122. subcc %o1, 1, %o1
  123. stb %g3, [%o0 + 4]
  124. be 0f
  125. subcc %o1, 1, %o1
  126. stb %g3, [%o0 + 5]
  127. be 0f
  128. subcc %o1, 1, %o1
  129. stb %g3, [%o0 + 6]
  130. 0: retl
  131. nop
  132. END(memset)
  133. weak_alias (__bzero, bzero)