memset.S 898 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2004-2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser General
  5. * Public License. See the file "COPYING.LIB" in the main directory of this
  6. * archive for more details.
  7. */
  8. #include <features.h>
  9. #define s r12
  10. #define c r11
  11. #define n r10
  12. .text
  13. .global memset
  14. .type memset, @function
  15. .align 1
  16. memset:
  17. cp.w n, 32
  18. mov r9, s
  19. brge .Llarge_memset
  20. sub n, 1
  21. retlt s
  22. 1: st.b s++, c
  23. sub n, 1
  24. brge 1b
  25. retal r9
  26. .Llarge_memset:
  27. mov r8, r11
  28. mov r11, 3
  29. bfins r8, r8, 8, 8
  30. bfins r8, r8, 16, 16
  31. tst s, r11
  32. breq 2f
  33. 1: st.b s++, r8
  34. sub n, 1
  35. tst s, r11
  36. brne 1b
  37. 2: mov r11, r9
  38. mov r9, r8
  39. sub n, 8
  40. 3: st.d s++, r8
  41. sub n, 8
  42. brge 3b
  43. /* If we are done, n == -8 and we'll skip all st.b insns below */
  44. neg n
  45. lsl n, 1
  46. add pc, n
  47. .rept 7
  48. st.b s++, r8
  49. .endr
  50. retal r11
  51. .size memset, . - memset
  52. libc_hidden_def(memset)