xref: /openbsd/lib/libc/arch/i386/string/bcmp.S (revision 9b7c3dbb)
1/*	$OpenBSD: bcmp.S,v 1.4 2015/08/31 02:53:56 guenther Exp $ */
2/*
3 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain.
5 */
6
7#include "SYS.h"
8
9ENTRY(bcmp)
10	pushl	%edi
11	pushl	%esi
12	movl	12(%esp),%edi
13	movl	16(%esp),%esi
14	xorl	%eax,%eax		/* clear return value */
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	L1
22
23	movl	20(%esp),%ecx		/* compare remainder by bytes */
24	andl	$3,%ecx
25	repe
26	cmpsb
27	je	L2
28
29L1:	incl	%eax
30L2:	popl	%esi
31	popl	%edi
32	ret
33END_WEAK(bcmp)
34