Annotation of sys/lib/libkern/arch/i386/memcmp.S, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: memcmp.S,v 1.1 2000/06/16 19:56:54 millert 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(memcmp)
! 11: pushl %edi
! 12: pushl %esi
! 13: movl 12(%esp),%edi
! 14: movl 16(%esp),%esi
! 15: cld /* set compare direction forward */
! 16:
! 17: movl 20(%esp),%ecx /* compare by words */
! 18: shrl $2,%ecx
! 19: repe
! 20: cmpsl
! 21: jne L5 /* do we match so far? */
! 22:
! 23: movl 20(%esp),%ecx /* compare remainder by bytes */
! 24: andl $3,%ecx
! 25: repe
! 26: cmpsb
! 27: jne L6 /* do we match? */
! 28:
! 29: xorl %eax,%eax /* we match, return zero */
! 30: popl %esi
! 31: popl %edi
! 32: ret
! 33:
! 34: L5: movl $4,%ecx /* We know that one of the next */
! 35: subl %ecx,%edi /* four pairs of bytes do not */
! 36: subl %ecx,%esi /* match. */
! 37: repe
! 38: cmpsb
! 39: L6: movzbl -1(%edi),%eax /* Perform unsigned comparison */
! 40: movzbl -1(%esi),%edx
! 41: subl %edx,%eax
! 42: popl %esi
! 43: popl %edi
! 44: ret
CVSweb