memset.S 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. * Copyright (C) 2007 ARC International (UK) LTD
  4. *
  5. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <sysdep.h>
  8. #define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
  9. ENTRY(memset)
  10. mov_s r4,r0
  11. or r12,r0,r2
  12. bmsk.f r12,r12,1
  13. extb_s r1,r1
  14. asl r3,r1,8
  15. beq.d .Laligned
  16. or_s r1,r1,r3
  17. brls r2,SMALL,.Ltiny
  18. add r3,r2,r0
  19. stb r1,[r3,-1]
  20. bclr_s r3,r3,0
  21. stw r1,[r3,-2]
  22. bmsk.f r12,r0,1
  23. add_s r2,r2,r12
  24. sub.ne r2,r2,4
  25. stb.ab r1,[r4,1]
  26. and r4,r4,-2
  27. stw.ab r1,[r4,2]
  28. and r4,r4,-4
  29. .Laligned: ; This code address should be aligned for speed.
  30. asl r3,r1,16
  31. lsr.f lp_count,r2,2
  32. or_s r1,r1,r3
  33. lpne .Loop_end
  34. st.ab r1,[r4,4]
  35. .Loop_end:
  36. j_s [blink]
  37. .balign 4
  38. .Ltiny:
  39. mov.f lp_count,r2
  40. lpne .Ltiny_end
  41. stb.ab r1,[r4,1]
  42. .Ltiny_end:
  43. j_s [blink]
  44. END(memset)
  45. libc_hidden_def(memset)