/	Copyright (c) 1984, 1986, 1987, 1988 AT&T
/	  All Rights Reserved

/	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
/	The copyright notice above does not evidence any
/	actual or intended publication of such source code.
	.file	"memcmp.s"

	.ident	"@(#)libc-i386:libc-i386/gen/memcmp.s	1.2"

	.globl	memcmp
	.align	4

/ This implementation conforms to SVID but does not implement
/ the same algorithm as the portable version because it is
/ inconvenient to get the difference of the differing characters.
/ Cannot compare word at a time because of byte ordering and
/ the comparison of chars is signed.

memcmp:
	MCOUNT			/ profiling
	movl	%edi,%edx	/ save register variables
	pushl	%esi
	movl	8(%esp),%esi	/ %esi = address of string 1
	movl	12(%esp),%edi	/ %edi = address of string 2
	cmpl	%esi,%edi	/ The same string?
	je	.equal

	movl	16(%esp),%ecx	/ %ecx = length
	testl	%ecx,%ecx	/ If a zero length string, set zero cc

	repz ; scmpb		/ compare the bytes
	je	.equal

.notequal:
	lahf			/ loads bit 15 with result of compare
	cwtl			/ make it + or - according to result
	popl	%esi
	movl	%edx,%edi
	ret	
.equal:
	popl	%esi
	movl	%edx,%edi
	xorl	%eax,%eax
	ret
