memset.S 1.8 KB

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