memset.s 558 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. TEXT memset(SB), $0
  2. MOVL n+8(FP), R0
  3. BLE return
  4. MOVL s1+0(FP), A1
  5. CLRL R1
  6. MOVB c+7(FP), R1
  7. BEQ l1
  8. /*
  9. * create 4 replicated copies
  10. * of the byte in R1
  11. */
  12. MOVL R1, R2
  13. ASLL $8, R2
  14. ORL R2, R1
  15. MOVL R1, R2
  16. SWAP R2
  17. ORL R2, R1
  18. /*
  19. * quad-long-at-a-time set
  20. * destination allignment is not
  21. * very important.
  22. */
  23. l1:
  24. SUBL $16, R0
  25. BLT l2
  26. MOVL R1, (A1)+
  27. MOVL R1, (A1)+
  28. MOVL R1, (A1)+
  29. MOVL R1, (A1)+
  30. BRA l1
  31. /*
  32. * cleanup byte-at-a-time
  33. */
  34. l2:
  35. ADDL $15, R0
  36. BLT return
  37. l3:
  38. MOVB R1, (A1)+
  39. SUBL $1, R0
  40. BGE l3
  41. return:
  42. MOVL s1+0(FP),R0
  43. RTS