memset.S 828 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* $Id: memset.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
  2. *
  3. * "memset" implementation of SuperH
  4. *
  5. * Copyright (C) 1999 Niibe Yutaka
  6. *
  7. */
  8. /*
  9. * void *memset(void *s, int c, size_t n);
  10. */
  11. #include <linux/linkage.h>
  12. ENTRY(memset)
  13. tst r6,r6
  14. bt/s 5f ! if n=0, do nothing
  15. add r6,r4
  16. mov #12,r0
  17. cmp/gt r6,r0
  18. bt/s 4f ! if it's too small, set a byte at once
  19. mov r4,r0
  20. and #3,r0
  21. cmp/eq #0,r0
  22. bt/s 2f ! It's aligned
  23. sub r0,r6
  24. 1:
  25. dt r0
  26. bf/s 1b
  27. mov.b r5,@-r4
  28. 2: ! make VVVV
  29. extu.b r5,r5
  30. swap.b r5,r0 ! V0
  31. or r0,r5 ! VV
  32. swap.w r5,r0 ! VV00
  33. or r0,r5 ! VVVV
  34. !
  35. mov r6,r0
  36. shlr2 r0
  37. shlr r0 ! r0 = r6 >> 3
  38. 3:
  39. dt r0
  40. mov.l r5,@-r4 ! set 8-byte at once
  41. bf/s 3b
  42. mov.l r5,@-r4
  43. !
  44. mov #7,r0
  45. and r0,r6
  46. tst r6,r6
  47. bt 5f
  48. ! fill bytes
  49. 4:
  50. dt r6
  51. bf/s 4b
  52. mov.b r5,@-r4
  53. 5:
  54. rts
  55. mov r4,r0