Annotation of sys/lib/libkern/arch/amd64/memcmp.S, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * Written by J.T. Conklin <jtc@netbsd.org>.
! 3: * Public domain.
! 4: * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
! 5: */
! 6:
! 7: #include <machine/asm.h>
! 8:
! 9: #if defined(LIBC_SCCS)
! 10: RCSID("$NetBSD: memcmp.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $")
! 11: #endif
! 12:
! 13: ENTRY(memcmp)
! 14: cld /* set compare direction forward */
! 15: movq %rdx,%rcx /* compare by longs */
! 16: shrq $3,%rcx
! 17: repe
! 18: cmpsq
! 19: jne L5 /* do we match so far? */
! 20:
! 21: movq %rdx,%rcx /* compare remainder by bytes */
! 22: andq $7,%rcx
! 23: repe
! 24: cmpsb
! 25: jne L6 /* do we match? */
! 26:
! 27: xorl %eax,%eax /* we match, return zero */
! 28: ret
! 29:
! 30: L5: movl $8,%ecx /* We know that one of the next */
! 31: subq %rcx,%rdi /* eight pairs of bytes do not */
! 32: subq %rcx,%rsi /* match. */
! 33: repe
! 34: cmpsb
! 35: L6: xorl %eax,%eax /* Perform unsigned comparison */
! 36: movb -1(%rdi),%al
! 37: xorl %edx,%edx
! 38: movb -1(%rsi),%dl
! 39: subl %edx,%eax
! 40: ret
CVSweb