Annotation of sys/lib/libkern/arch/i386/memset.S, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: memset.S,v 1.3 2007/05/25 20:32:29 krw Exp $ */
! 2:
! 3: /*
! 4: * Written by J.T. Conklin <jtc@netbsd.org>.
! 5: * Public domain.
! 6: */
! 7:
! 8: #include <machine/asm.h>
! 9:
! 10: ENTRY(memset)
! 11: pushl %edi
! 12: pushl %ebx
! 13: movl 12(%esp),%edi
! 14: movzbl 16(%esp),%eax /* unsigned char, zero extend */
! 15: movl 20(%esp),%ecx
! 16: pushl %edi /* push address of buffer */
! 17:
! 18: cld /* set fill direction forward */
! 19:
! 20: /*
! 21: * if the string is too short, it's really not worth the overhead
! 22: * of aligning to word boundaries, etc. So we jump to a plain
! 23: * unaligned set.
! 24: */
! 25: cmpl $0x0f,%ecx
! 26: jle L1
! 27:
! 28: movb %al,%ah /* copy char to all bytes in word */
! 29: movl %eax,%edx
! 30: sall $16,%eax
! 31: orl %edx,%eax
! 32:
! 33: movl %edi,%edx /* compute misalignment */
! 34: negl %edx
! 35: andl $3,%edx
! 36: movl %ecx,%ebx
! 37: subl %edx,%ebx
! 38:
! 39: movl %edx,%ecx /* set until word aligned */
! 40: rep
! 41: stosb
! 42:
! 43: movl %ebx,%ecx
! 44: shrl $2,%ecx /* set by words */
! 45: rep
! 46: stosl
! 47:
! 48: movl %ebx,%ecx /* set remainder by bytes */
! 49: andl $3,%ecx
! 50: L1: rep
! 51: stosb
! 52:
! 53: popl %eax /* pop address of buffer */
! 54: popl %ebx
! 55: popl %edi
! 56: ret
CVSweb