strcmp.S revision 85437
11849Swollman/*
21849Swollman * Copyright (c) 1993 Winning Strategies, Inc.
31849Swollman * All rights reserved.
41849Swollman *
51849Swollman * Redistribution and use in source and binary forms, with or without
61849Swollman * modification, are permitted provided that the following conditions
71849Swollman * are met:
81849Swollman * 1. Redistributions of source code must retain the above copyright
91849Swollman *    notice, this list of conditions and the following disclaimer.
101849Swollman * 2. Redistributions in binary form must reproduce the above copyright
111849Swollman *    notice, this list of conditions and the following disclaimer in the
121849Swollman *    documentation and/or other materials provided with the distribution.
131849Swollman * 3. All advertising materials mentioning features or use of this software
141849Swollman *    must display the following acknowledgement:
151849Swollman *      This product includes software developed by Winning Strategies, Inc.
161849Swollman * 4. The name of the author may not be used to endorse or promote products
171849Swollman *    derived from this software withough specific prior written permission
181849Swollman *
191849Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
201849Swollman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
211849Swollman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
221849Swollman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
231849Swollman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
241849Swollman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
251849Swollman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261849Swollman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271849Swollman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
281849Swollman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291849Swollman */
301849Swollman
311849Swollman#if defined(LIBC_RCS) && !defined(lint)
325790Sdg	.text
3350476Speter        .asciz "$FreeBSD: head/lib/libc/i386/string/strcmp.S 85437 2001-10-24 20:29:14Z peter $"
341849Swollman#endif /* LIBC_RCS and not lint */
351849Swollman
3685437Speter#include <machine/asm.h>
371849Swollman
381849Swollman/*
391849Swollman * strcmp(s1, s2)
401849Swollman *	return an integer greater than, equal to, or less than 0,
411849Swollman *	according as string s1 is greater than, equal to, or less
421849Swollman *	than the string s2.
431849Swollman *
441849Swollman * %eax - pointer to s1
451849Swollman * %edx - pointer to s2
461849Swollman *
471849Swollman * Written by:
481849Swollman *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
491849Swollman */
501849Swollman
511849Swollman/*
521849Swollman * I've unrolled the loop eight times: large enough to make a
531849Swollman * significant difference, and small enough not to totally trash the
541849Swollman * cashe.
551849Swollman */
561849Swollman
571849SwollmanENTRY(strcmp)
581849Swollman	movl	0x04(%esp),%eax
591849Swollman	movl	0x08(%esp),%edx
601849Swollman	jmp	L2			/* Jump into the loop! */
611849Swollman
621849Swollman	.align	2,0x90
631849SwollmanL1:	incl	%eax
641849Swollman	incl	%edx
651849SwollmanL2:	movb	(%eax),%cl
661849Swollman	testb	%cl,%cl
671849Swollman	je	L3
681849Swollman	cmpb	%cl,(%edx)
691849Swollman	jne	L3
701849Swollman	incl	%eax
711849Swollman	incl	%edx
721849Swollman	movb	(%eax),%cl
731849Swollman	testb	%cl,%cl
741849Swollman	je	L3
751849Swollman	cmpb	%cl,(%edx)
761849Swollman	jne	L3
771849Swollman	incl	%eax
781849Swollman	incl	%edx
791849Swollman	movb	(%eax),%cl
801849Swollman	testb	%cl,%cl
811849Swollman	je	L3
821849Swollman	cmpb	%cl,(%edx)
831849Swollman	jne	L3
841849Swollman	incl	%eax
851849Swollman	incl	%edx
861849Swollman	movb	(%eax),%cl
871849Swollman	testb	%cl,%cl
881849Swollman	je	L3
891849Swollman	cmpb	%cl,(%edx)
901849Swollman	jne	L3
911849Swollman	incl	%eax
921849Swollman	incl	%edx
931849Swollman	movb	(%eax),%cl
941849Swollman	testb	%cl,%cl
951849Swollman	je	L3
961849Swollman	cmpb	%cl,(%edx)
971849Swollman	jne	L3
981849Swollman	incl	%eax
991849Swollman	incl	%edx
1001849Swollman	movb	(%eax),%cl
1011849Swollman	testb	%cl,%cl
1021849Swollman	je	L3
1031849Swollman	cmpb	%cl,(%edx)
1041849Swollman	jne	L3
1051849Swollman	incl	%eax
1061849Swollman	incl	%edx
1071849Swollman	movb	(%eax),%cl
1081849Swollman	testb	%cl,%cl
1091849Swollman	je	L3
1101849Swollman	cmpb	%cl,(%edx)
1111849Swollman	jne	L3
1121849Swollman	incl	%eax
1131849Swollman	incl	%edx
1141849Swollman	movb	(%eax),%cl
1151849Swollman	testb	%cl,%cl
1161849Swollman	je	L3
1171849Swollman	cmpb	%cl,(%edx)
1181849Swollman	je	L1
1191849Swollman	.align 2, 0x90
1201849SwollmanL3:     movzbl  (%eax),%eax             /* unsigned comparison */
1211849Swollman	movzbl  (%edx),%edx
1221849Swollman	subl	%edx,%eax
1231849Swollman	ret
124