memset.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. moveq pc, lr @ nope
  54. rsb a3, a3, $7
  55. add pc, pc, a3, lsl $2
  56. mov r0, r0
  57. strb a2, [a4], $1
  58. strb a2, [a4], $1
  59. strb a2, [a4], $1
  60. strb a2, [a4], $1
  61. strb a2, [a4], $1
  62. strb a2, [a4], $1
  63. strb a2, [a4], $1
  64. mov pc, lr
  65. .size memset,.-memset
  66. libc_hidden_def(memset)