1 /* 2 * Written by J.T. Conklin <jtc (at) NetBSD.org>. 3 * Public domain. 4 */ 5 6 #include <machine/asm.h> 7 8 #if defined(LIBC_SCCS) 9 RCSID("$NetBSD: bcmp.S,v 1.8 2003/07/26 19:24:33 salo Exp $") 10 #endif 11 12 ENTRY(bcmp) 13 pushl %edi 14 pushl %esi 15 movl 12(%esp),%edi 16 movl 16(%esp),%esi 17 xorl %eax,%eax /* clear return value */ 18 cld /* set compare direction forward */ 19 20 movl 20(%esp),%ecx /* compare by words */ 21 shrl $2,%ecx 22 repe 23 cmpsl 24 jne L1 25 26 movl 20(%esp),%ecx /* compare remainder by bytes */ 27 andl $3,%ecx 28 repe 29 cmpsb 30 je L2 31 32 L1: incl %eax 33 L2: popl %esi 34 popl %edi 35 ret 36