2 * Written by J.T. Conklin <jtc@NetBSD.org>.
4 * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
6 * $NetBSD: memcmp.S,v 1.2 2003/07/26 19:24:39 salo Exp $
7 * $FreeBSD: src/lib/libc/amd64/string/memcmp.S,v 1.2 2008/11/02 01:10:54 peter Exp $
10 #include <machine/asm.h>
13 cld /* set compare direction forward */
14 movq %rdx,%rcx /* compare by longs */
18 jne L5 /* do we match so far? */
20 movq %rdx,%rcx /* compare remainder by bytes */
24 jne L6 /* do we match? */
26 xorl %eax,%eax /* we match, return zero */
29 L5: movl $8,%ecx /* We know that one of the next */
30 subq %rcx,%rdi /* eight pairs of bytes do not */
31 subq %rcx,%rsi /* match. */
34 L6: xorl %eax,%eax /* Perform unsigned comparison */