memset.S 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* memset.S */
  3. #include <asm/linkage.h>
  4. #if defined(CONFIG_CPU_H8300H)
  5. .h8300h
  6. #endif
  7. #if defined(CONFIG_CPU_H8S)
  8. .h8300s
  9. #endif
  10. .text
  11. .global memset
  12. .global clear_user
  13. ;;void *memset(*ptr, int c, size_t count)
  14. ;; ptr = er0
  15. ;; c = er1(r1l)
  16. ;; count = er2
  17. memset:
  18. btst #0,r0l
  19. beq 2f
  20. ;; odd address
  21. 1:
  22. mov.b r1l,@er0
  23. adds #1,er0
  24. dec.l #1,er2
  25. beq 6f
  26. ;; even address
  27. 2:
  28. mov.l er2,er3
  29. cmp.l #4,er2
  30. blo 4f
  31. ;; count>=4 -> count/4
  32. #if defined(CONFIG_CPU_H8300H)
  33. shlr.l er2
  34. shlr.l er2
  35. #endif
  36. #if defined(CONFIG_CPU_H8S)
  37. shlr.l #2,er2
  38. #endif
  39. ;; byte -> long
  40. mov.b r1l,r1h
  41. mov.w r1,e1
  42. 3:
  43. mov.l er1,@er0
  44. adds #4,er0
  45. dec.l #1,er2
  46. bne 3b
  47. 4:
  48. ;; count % 4
  49. and.b #3,r3l
  50. beq 6f
  51. 5:
  52. mov.b r1l,@er0
  53. adds #1,er0
  54. dec.b r3l
  55. bne 5b
  56. 6:
  57. rts
  58. clear_user:
  59. mov.l er1, er2
  60. sub.l er1, er1
  61. bra memset
  62. .end