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 <sys/syscall.h>
  17. .global memset
  18. .set memset,__memset
  19. .text
  20. .global __memset
  21. .hidden __memset
  22. .type __memset,%function
  23. .align 4
  24. __memset:
  25. mov a4, a1
  26. cmp a3, $8 @ at least 8 bytes to do?
  27. blt 2f
  28. orr a2, a2, a2, lsl $8
  29. orr a2, a2, a2, lsl $16
  30. 1:
  31. tst a4, $3 @ aligned yet?
  32. strneb a2, [a4], $1
  33. subne a3, a3, $1
  34. bne 1b
  35. mov ip, a2
  36. 1:
  37. cmp a3, $8 @ 8 bytes still to do?
  38. blt 2f
  39. stmia a4!, {a2, ip}
  40. sub a3, a3, $8
  41. cmp a3, $8 @ 8 bytes still to do?
  42. blt 2f
  43. stmia a4!, {a2, ip}
  44. sub a3, a3, $8
  45. cmp a3, $8 @ 8 bytes still to do?
  46. blt 2f
  47. stmia a4!, {a2, ip}
  48. sub a3, a3, $8
  49. cmp a3, $8 @ 8 bytes still to do?
  50. stmgeia a4!, {a2, ip}
  51. subge a3, a3, $8
  52. bge 1b
  53. 2:
  54. movs a3, a3 @ anything left?
  55. moveq pc, lr @ nope
  56. rsb a3, a3, $7
  57. add pc, pc, a3, lsl $2
  58. mov r0, r0
  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. strb a2, [a4], $1
  65. strb a2, [a4], $1
  66. mov pc, lr
  67. .size __memset,.-__memset