memset.S 1.8 KB

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