xref: /openbsd-src/lib/libc/arch/amd64/string/bcmp.S (revision ec0f1ad61759066f4a02361ba4c792430af069db)
1b4551fdeSguenther#include "DEFS.h"
25b859c19Sderaadt
3*ec0f1ad6SguentherENTRY_NB(bcmp)
4631951aaSmortimer	RETGUARD_SETUP(bcmp, r11)
55b859c19Sderaadt	xorl	%eax,%eax		/* clear return value */
65b859c19Sderaadt	cld				/* set compare direction forward */
75b859c19Sderaadt
85b859c19Sderaadt	movq	%rdx,%rcx		/* compare by words */
95b859c19Sderaadt	shrq	$3,%rcx
105b859c19Sderaadt	repe
115b859c19Sderaadt	cmpsq
125b859c19Sderaadt	jne	L1
135b859c19Sderaadt
145b859c19Sderaadt	movq	%rdx,%rcx		/* compare remainder by bytes */
155b859c19Sderaadt	andq	$7,%rcx
165b859c19Sderaadt	repe
175b859c19Sderaadt	cmpsb
185b859c19Sderaadt	je	L2
195b859c19Sderaadt
205b859c19SderaadtL1:	incl	%eax
21631951aaSmortimerL2:	RETGUARD_CHECK(bcmp, r11)
22631951aaSmortimer	ret
239b9d2a55SguentherEND_WEAK(bcmp)
24