memset-386.s 396 B

1234567891011121314151617181920212223242526272829303132333435
  1. TEXT memset(SB),$0
  2. CLD
  3. MOVL p+0(FP), DI
  4. MOVBLZX c+4(FP), AX
  5. MOVL n+8(FP), BX
  6. /*
  7. * if not enough bytes, just copy
  8. */
  9. CMPL BX, $9
  10. JLS c3
  11. /*
  12. * build word in AX
  13. */
  14. MOVB AL, AH
  15. MOVL AX, CX
  16. SHLL $16, CX
  17. ORL CX, AX
  18. /*
  19. * copy whole longs
  20. */
  21. c1:
  22. MOVL BX, CX
  23. SHRL $2, CX
  24. ANDL $3, BX
  25. REP; STOSL
  26. /*
  27. * copy the rest, by bytes
  28. */
  29. c3:
  30. MOVL BX, CX
  31. REP; STOSB
  32. ret:
  33. MOVL p+0(FP),AX
  34. RET