memset.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #include <features.h>
  20. /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */
  21. #define ZERO_BIG_BLOCK(base, offset, source) \
  22. std source, [base + offset + 0x00]; \
  23. std source, [base + offset + 0x08]; \
  24. std source, [base + offset + 0x10]; \
  25. std source, [base + offset + 0x18]; \
  26. std source, [base + offset + 0x20]; \
  27. std source, [base + offset + 0x28]; \
  28. std source, [base + offset + 0x30]; \
  29. std source, [base + offset + 0x38];
  30. #define ZERO_LAST_BLOCKS(base, offset, source) \
  31. std source, [base - offset - 0x38]; \
  32. std source, [base - offset - 0x30]; \
  33. std source, [base - offset - 0x28]; \
  34. std source, [base - offset - 0x20]; \
  35. std source, [base - offset - 0x18]; \
  36. std source, [base - offset - 0x10]; \
  37. std source, [base - offset - 0x08]; \
  38. std source, [base - offset - 0x00];
  39. .text
  40. .align 4
  41. #ifdef __UCLIBC_SUSV3_LEGACY__
  42. ENTRY(bzero)
  43. b 1f
  44. mov %g0, %g3
  45. #endif
  46. 3: cmp %o2, 3
  47. be 2f
  48. stb %g3, [%o0]
  49. cmp %o2, 2
  50. be 2f
  51. stb %g3, [%o0 + 0x01]
  52. stb %g3, [%o0 + 0x02]
  53. 2: sub %o2, 4, %o2
  54. add %o1, %o2, %o1
  55. b 4f
  56. sub %o0, %o2, %o0
  57. #ifdef __UCLIBC_SUSV3_LEGACY__
  58. END(bzero)
  59. #endif
  60. ENTRY(memset)
  61. and %o1, 0xff, %g3
  62. sll %g3, 8, %g2
  63. or %g3, %g2, %g3
  64. sll %g3, 16, %g2
  65. or %g3, %g2, %g3
  66. orcc %o2, %g0, %o1
  67. 1: cmp %o1, 7
  68. bleu 7f
  69. mov %o0, %g1
  70. andcc %o0, 3, %o2
  71. bne 3b
  72. 4: andcc %o0, 4, %g0
  73. be 2f
  74. mov %g3, %g2
  75. st %g3, [%o0]
  76. sub %o1, 4, %o1
  77. add %o0, 4, %o0
  78. 2: andcc %o1, 0xffffff80, %o3
  79. be 9f
  80. andcc %o1, 0x78, %o2
  81. 4: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
  82. subcc %o3, 128, %o3
  83. ZERO_BIG_BLOCK (%o0, 0x40, %g2)
  84. bne 4b
  85. add %o0, 128, %o0
  86. orcc %o2, %g0, %g0
  87. 9: be 6f
  88. andcc %o1, 7, %o1
  89. mov %o7, %g4
  90. 101: call 100f
  91. srl %o2, 1, %o3
  92. mov %g4, %o7
  93. jmpl %o4 + (20f + 64 - 101b), %g0
  94. add %o0, %o2, %o0
  95. 100: retl
  96. sub %o7, %o3, %o4
  97. 20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
  98. ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
  99. 6: be 8f
  100. andcc %o1, 4, %g0
  101. be 1f
  102. andcc %o1, 2, %g0
  103. st %g3, [%o0]
  104. add %o0, 4, %o0
  105. 1: be 1f
  106. andcc %o1, 1, %g0
  107. sth %g3, [%o0]
  108. add %o0, 2, %o0
  109. 1: bne,a 8f
  110. stb %g3, [%o0]
  111. 8: retl
  112. mov %g1, %o0
  113. 7: orcc %o1, 0, %g0
  114. be 0f
  115. subcc %o1, 1, %o1
  116. stb %g3, [%o0]
  117. be 0f
  118. subcc %o1, 1, %o1
  119. stb %g3, [%o0 + 1]
  120. be 0f
  121. subcc %o1, 1, %o1
  122. stb %g3, [%o0 + 2]
  123. be 0f
  124. subcc %o1, 1, %o1
  125. stb %g3, [%o0 + 3]
  126. be 0f
  127. subcc %o1, 1, %o1
  128. stb %g3, [%o0 + 4]
  129. be 0f
  130. subcc %o1, 1, %o1
  131. stb %g3, [%o0 + 5]
  132. be 0f
  133. subcc %o1, 1, %o1
  134. stb %g3, [%o0 + 6]
  135. 0: retl
  136. nop
  137. END(memset)
  138. libc_hidden_def(memset)