memset.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 1998 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Philip Blundell <philb@gnu.org>
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include <features.h>
  17. #include <sys/syscall.h>
  18. .text
  19. .global memset
  20. .type memset,%function
  21. .align 4
  22. memset:
  23. mov a4, a1
  24. cmp a3, $8 @ at least 8 bytes to do?
  25. blt 2f
  26. orr a2, a2, a2, lsl $8
  27. orr a2, a2, a2, lsl $16
  28. 1:
  29. tst a4, $3 @ aligned yet?
  30. strneb a2, [a4], $1
  31. subne a3, a3, $1
  32. bne 1b
  33. mov ip, a2
  34. 1:
  35. cmp a3, $8 @ 8 bytes still to do?
  36. blt 2f
  37. stmia a4!, {a2, ip}
  38. sub a3, a3, $8
  39. cmp a3, $8 @ 8 bytes still to do?
  40. blt 2f
  41. stmia a4!, {a2, ip}
  42. sub a3, a3, $8
  43. cmp a3, $8 @ 8 bytes still to do?
  44. blt 2f
  45. stmia a4!, {a2, ip}
  46. sub a3, a3, $8
  47. cmp a3, $8 @ 8 bytes still to do?
  48. stmgeia a4!, {a2, ip}
  49. subge a3, a3, $8
  50. bge 1b
  51. 2:
  52. movs a3, a3 @ anything left?
  53. #if defined(__USE_BX__)
  54. bxeq lr
  55. #else
  56. moveq pc, lr @ nope
  57. #endif
  58. rsb a3, a3, $7
  59. add pc, pc, a3, lsl $2
  60. mov r0, r0
  61. strb a2, [a4], $1
  62. strb a2, [a4], $1
  63. strb a2, [a4], $1
  64. strb a2, [a4], $1
  65. strb a2, [a4], $1
  66. strb a2, [a4], $1
  67. strb a2, [a4], $1
  68. #if defined(__USE_BX__)
  69. bx lr
  70. #else
  71. mov pc, lr
  72. #endif
  73. .size memset,.-memset
  74. libc_hidden_def(memset)