bzero.S 760 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* $OpenBSD: bzero.S,v 1.5 2014/11/29 18:51:23 tedu Exp $ */
  2. /*
  3. * Written by J.T. Conklin <jtc@netbsd.org>.
  4. * Public domain.
  5. */
  6. #include <machine/asm.h>
  7. #ifndef _KERNEL
  8. ENTRY(bzero)
  9. pushl %edi
  10. movl 8(%esp),%edi
  11. movl 12(%esp),%edx
  12. xorl %eax,%eax /* set fill data to 0 */
  13. /*
  14. * if the string is too short, it's really not worth the overhead
  15. * of aligning to word boundaries, etc. So we jump to a plain
  16. * unaligned set.
  17. */
  18. cmpl $16,%edx
  19. jb L1
  20. movl %edi,%ecx /* compute misalignment */
  21. negl %ecx
  22. andl $3,%ecx
  23. subl %ecx,%edx
  24. rep /* zero until word aligned */
  25. stosb
  26. movl %edx,%ecx /* zero by words */
  27. shrl $2,%ecx
  28. andl $3,%edx
  29. rep
  30. stosl
  31. L1: movl %edx,%ecx /* zero remainder by bytes */
  32. rep
  33. stosb
  34. popl %edi
  35. ret
  36. #endif