xref: /openbsd-src/sys/lib/libkern/arch/i386/bcmp.S (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1/*	$OpenBSD: bcmp.S,v 1.2 1996/09/27 06:47:44 mickey Exp $	*/
2
3/*
4 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Public domain.
6 */
7
8#include <machine/asm.h>
9
10ENTRY(bcmp)
11	pushl	%edi
12	pushl	%esi
13	movl	12(%esp),%edi
14	movl	16(%esp),%esi
15	xorl	%eax,%eax		/* clear return value */
16	cld				/* set compare direction forward */
17
18	movl	20(%esp),%ecx		/* compare by words */
19	shrl	$2,%ecx
20	repe
21	cmpsl
22	jne	L1
23
24	movl	20(%esp),%ecx		/* compare remainder by bytes */
25	andl	$3,%ecx
26	repe
27	cmpsb
28	je	L2
29
30L1:	incl	%eax
31L2:	popl	%esi
32	popl	%edi
33	ret
34