]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/i386/string/strcmp.S
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / i386 / string / strcmp.S
1 /*
2  * Copyright (c) 1993 Winning Strategies, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by Winning Strategies, Inc.
16  * 4. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include <machine/asm.h>
32 __FBSDID("$FreeBSD$");
33
34 /*
35  * strcmp(s1, s2)
36  *      return an integer greater than, equal to, or less than 0, 
37  *      according as string s1 is greater than, equal to, or less
38  *      than the string s2.  
39  *
40  * %eax - pointer to s1
41  * %edx - pointer to s2
42  *
43  * Written by:
44  *      J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
45  */
46
47 /*
48  * I've unrolled the loop eight times: large enough to make a
49  * significant difference, and small enough not to totally trash the
50  * cache.
51  */
52
53 ENTRY(strcmp)
54         movl    0x04(%esp),%eax 
55         movl    0x08(%esp),%edx 
56         jmp     L2                      /* Jump into the loop! */
57
58         .align  2,0x90
59 L1:     incl    %eax
60         incl    %edx                    
61 L2:     movb    (%eax),%cl
62         testb   %cl,%cl
63         je      L3
64         cmpb    %cl,(%edx)
65         jne     L3
66         incl    %eax
67         incl    %edx
68         movb    (%eax),%cl
69         testb   %cl,%cl
70         je      L3
71         cmpb    %cl,(%edx)
72         jne     L3
73         incl    %eax
74         incl    %edx
75         movb    (%eax),%cl
76         testb   %cl,%cl
77         je      L3
78         cmpb    %cl,(%edx)
79         jne     L3
80         incl    %eax
81         incl    %edx
82         movb    (%eax),%cl
83         testb   %cl,%cl
84         je      L3
85         cmpb    %cl,(%edx)
86         jne     L3
87         incl    %eax
88         incl    %edx
89         movb    (%eax),%cl
90         testb   %cl,%cl
91         je      L3
92         cmpb    %cl,(%edx)
93         jne     L3
94         incl    %eax
95         incl    %edx
96         movb    (%eax),%cl
97         testb   %cl,%cl
98         je      L3
99         cmpb    %cl,(%edx)
100         jne     L3
101         incl    %eax
102         incl    %edx
103         movb    (%eax),%cl
104         testb   %cl,%cl
105         je      L3
106         cmpb    %cl,(%edx)
107         jne     L3
108         incl    %eax
109         incl    %edx
110         movb    (%eax),%cl
111         testb   %cl,%cl
112         je      L3
113         cmpb    %cl,(%edx)
114         je      L1
115         .align 2, 0x90
116 L3:     movzbl  (%eax),%eax             /* unsigned comparison */
117         movzbl  (%edx),%edx
118         subl    %edx,%eax
119         ret
120 END(strcmp)
121
122         .section .note.GNU-stack,"",%progbits