memset.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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, see
  17. <http://www.gnu.org/licenses/>. */
  18. #include <features.h>
  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. #ifdef __UCLIBC_SUSV3_LEGACY__
  41. ENTRY(bzero)
  42. b 1f
  43. mov %g0, %g3
  44. #endif
  45. 3: cmp %o2, 3
  46. be 2f
  47. stb %g3, [%o0]
  48. cmp %o2, 2
  49. be 2f
  50. stb %g3, [%o0 + 0x01]
  51. stb %g3, [%o0 + 0x02]
  52. 2: sub %o2, 4, %o2
  53. add %o1, %o2, %o1
  54. b 4f
  55. sub %o0, %o2, %o0
  56. #ifdef __UCLIBC_SUSV3_LEGACY__
  57. END(bzero)
  58. #endif
  59. ENTRY(memset)
  60. and %o1, 0xff, %g3
  61. sll %g3, 8, %g2
  62. or %g3, %g2, %g3
  63. sll %g3, 16, %g2
  64. or %g3, %g2, %g3
  65. orcc %o2, %g0, %o1
  66. 1: cmp %o1, 7
  67. bleu 7f
  68. mov %o0, %g1
  69. andcc %o0, 3, %o2
  70. bne 3b
  71. 4: andcc %o0, 4, %g0
  72. be 2f
  73. mov %g3, %g2
  74. st %g3, [%o0]
  75. sub %o1, 4, %o1
  76. add %o0, 4, %o0
  77. 2: andcc %o1, 0xffffff80, %o3
  78. be 9f
  79. andcc %o1, 0x78, %o2
  80. 4: ZERO_BIG_BLOCK (%o0, 0x00, %g2)
  81. subcc %o3, 128, %o3
  82. ZERO_BIG_BLOCK (%o0, 0x40, %g2)
  83. bne 4b
  84. add %o0, 128, %o0
  85. orcc %o2, %g0, %g0
  86. 9: be 6f
  87. andcc %o1, 7, %o1
  88. mov %o7, %g4
  89. 101: call 100f
  90. srl %o2, 1, %o3
  91. mov %g4, %o7
  92. jmpl %o4 + (20f + 64 - 101b), %g0
  93. add %o0, %o2, %o0
  94. 100: retl
  95. sub %o7, %o3, %o4
  96. 20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2)
  97. ZERO_LAST_BLOCKS(%o0, 0x08, %g2)
  98. 6: be 8f
  99. andcc %o1, 4, %g0
  100. be 1f
  101. andcc %o1, 2, %g0
  102. st %g3, [%o0]
  103. add %o0, 4, %o0
  104. 1: be 1f
  105. andcc %o1, 1, %g0
  106. sth %g3, [%o0]
  107. add %o0, 2, %o0
  108. 1: bne,a 8f
  109. stb %g3, [%o0]
  110. 8: retl
  111. mov %g1, %o0
  112. 7: orcc %o1, 0, %g0
  113. be 0f
  114. subcc %o1, 1, %o1
  115. stb %g3, [%o0]
  116. be 0f
  117. subcc %o1, 1, %o1
  118. stb %g3, [%o0 + 1]
  119. be 0f
  120. subcc %o1, 1, %o1
  121. stb %g3, [%o0 + 2]
  122. be 0f
  123. subcc %o1, 1, %o1
  124. stb %g3, [%o0 + 3]
  125. be 0f
  126. subcc %o1, 1, %o1
  127. stb %g3, [%o0 + 4]
  128. be 0f
  129. subcc %o1, 1, %o1
  130. stb %g3, [%o0 + 5]
  131. be 0f
  132. subcc %o1, 1, %o1
  133. stb %g3, [%o0 + 6]
  134. 0: retl
  135. nop
  136. END(memset)
  137. libc_hidden_def(memset)