/*1* Copyright (c) 1993 Winning Strategies, Inc.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by Winning Strategies, Inc.15* 4. The name of the author may not be used to endorse or promote products16* derived from this software without specific prior written permission17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/2930#include <machine/asm.h>31/*32* strcmp(s1, s2)33* return an integer greater than, equal to, or less than 0,34* according as string s1 is greater than, equal to, or less35* than the string s2.36*37* %eax - pointer to s138* %edx - pointer to s239*40* Written by:41* J.T. Conklin ([email protected]), Winning Strategies, Inc.42*/4344/*45* I've unrolled the loop eight times: large enough to make a46* significant difference, and small enough not to totally trash the47* cache.48*/4950ENTRY(strcmp)51movl 0x04(%esp),%eax52movl 0x08(%esp),%edx53jmp L2 /* Jump into the loop! */5455.align 2,0x9056L1: incl %eax57incl %edx58L2: movb (%eax),%cl59testb %cl,%cl60je L361cmpb %cl,(%edx)62jne L363incl %eax64incl %edx65movb (%eax),%cl66testb %cl,%cl67je L368cmpb %cl,(%edx)69jne L370incl %eax71incl %edx72movb (%eax),%cl73testb %cl,%cl74je L375cmpb %cl,(%edx)76jne L377incl %eax78incl %edx79movb (%eax),%cl80testb %cl,%cl81je L382cmpb %cl,(%edx)83jne L384incl %eax85incl %edx86movb (%eax),%cl87testb %cl,%cl88je L389cmpb %cl,(%edx)90jne L391incl %eax92incl %edx93movb (%eax),%cl94testb %cl,%cl95je L396cmpb %cl,(%edx)97jne L398incl %eax99incl %edx100movb (%eax),%cl101testb %cl,%cl102je L3103cmpb %cl,(%edx)104jne L3105incl %eax106incl %edx107movb (%eax),%cl108testb %cl,%cl109je L3110cmpb %cl,(%edx)111je L1112.align 2, 0x90113L3: movzbl (%eax),%eax /* unsigned comparison */114movzbl (%edx),%edx115subl %edx,%eax116ret117END(strcmp)118119.section .note.GNU-stack,"",%progbits120121122