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
1797748Sschweikh *    derived from this software without 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
3185437Speter#include <machine/asm.h>
3293000Sobrien__FBSDID("$FreeBSD$");
331849Swollman
341849Swollman/*
351849Swollman * strcmp(s1, s2)
361849Swollman *	return an integer greater than, equal to, or less than 0,
371849Swollman *	according as string s1 is greater than, equal to, or less
381849Swollman *	than the string s2.
391849Swollman *
401849Swollman * %eax - pointer to s1
411849Swollman * %edx - pointer to s2
421849Swollman *
431849Swollman * Written by:
441849Swollman *	J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
451849Swollman */
461849Swollman
471849Swollman/*
481849Swollman * I've unrolled the loop eight times: large enough to make a
491849Swollman * significant difference, and small enough not to totally trash the
5091999Sbillf * cache.
511849Swollman */
521849Swollman
531849SwollmanENTRY(strcmp)
541849Swollman	movl	0x04(%esp),%eax
551849Swollman	movl	0x08(%esp),%edx
561849Swollman	jmp	L2			/* Jump into the loop! */
571849Swollman
581849Swollman	.align	2,0x90
591849SwollmanL1:	incl	%eax
601849Swollman	incl	%edx
611849SwollmanL2:	movb	(%eax),%cl
621849Swollman	testb	%cl,%cl
631849Swollman	je	L3
641849Swollman	cmpb	%cl,(%edx)
651849Swollman	jne	L3
661849Swollman	incl	%eax
671849Swollman	incl	%edx
681849Swollman	movb	(%eax),%cl
691849Swollman	testb	%cl,%cl
701849Swollman	je	L3
711849Swollman	cmpb	%cl,(%edx)
721849Swollman	jne	L3
731849Swollman	incl	%eax
741849Swollman	incl	%edx
751849Swollman	movb	(%eax),%cl
761849Swollman	testb	%cl,%cl
771849Swollman	je	L3
781849Swollman	cmpb	%cl,(%edx)
791849Swollman	jne	L3
801849Swollman	incl	%eax
811849Swollman	incl	%edx
821849Swollman	movb	(%eax),%cl
831849Swollman	testb	%cl,%cl
841849Swollman	je	L3
851849Swollman	cmpb	%cl,(%edx)
861849Swollman	jne	L3
871849Swollman	incl	%eax
881849Swollman	incl	%edx
891849Swollman	movb	(%eax),%cl
901849Swollman	testb	%cl,%cl
911849Swollman	je	L3
921849Swollman	cmpb	%cl,(%edx)
931849Swollman	jne	L3
941849Swollman	incl	%eax
951849Swollman	incl	%edx
961849Swollman	movb	(%eax),%cl
971849Swollman	testb	%cl,%cl
981849Swollman	je	L3
991849Swollman	cmpb	%cl,(%edx)
1001849Swollman	jne	L3
1011849Swollman	incl	%eax
1021849Swollman	incl	%edx
1031849Swollman	movb	(%eax),%cl
1041849Swollman	testb	%cl,%cl
1051849Swollman	je	L3
1061849Swollman	cmpb	%cl,(%edx)
1071849Swollman	jne	L3
1081849Swollman	incl	%eax
1091849Swollman	incl	%edx
1101849Swollman	movb	(%eax),%cl
1111849Swollman	testb	%cl,%cl
1121849Swollman	je	L3
1131849Swollman	cmpb	%cl,(%edx)
1141849Swollman	je	L1
1151849Swollman	.align 2, 0x90
1161849SwollmanL3:     movzbl  (%eax),%eax             /* unsigned comparison */
1171849Swollman	movzbl  (%edx),%edx
1181849Swollman	subl	%edx,%eax
1191849Swollman	ret
120184548SpeterEND(strcmp)
121217106Skib
122217106Skib	.section .note.GNU-stack,"",%progbits
123