]> git.saurik.com Git - apple/libc.git/blob - string/strcmp.s
Libc-262.3.2.tar.gz
[apple/libc.git] / string / strcmp.s
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 .text
26 .globl _strcmp
27 _strcmp:
28 #if defined(__i386__)
29 movl 0x04(%esp),%eax
30 movl 0x08(%esp),%edx
31 jmp L2 /* Jump into the loop! */
32
33 .align 2,0x90
34 L1: incl %eax
35 incl %edx
36 L2: movb (%eax),%cl
37 testb %cl,%cl /* null terminator??? */
38 jz L3
39 cmpb %cl,(%edx) /* chars match??? */
40 jne L3
41 incl %eax
42 incl %edx
43 movb (%eax),%cl
44 testb %cl,%cl
45 jz L3
46 cmpb %cl,(%edx)
47 jne L3
48 incl %eax
49 incl %edx
50 movb (%eax),%cl
51 testb %cl,%cl
52 jz L3
53 cmpb %cl,(%edx)
54 jne L3
55 incl %eax
56 incl %edx
57 movb (%eax),%cl
58 testb %cl,%cl
59 jz L3
60 cmpb %cl,(%edx)
61 jne L3
62 incl %eax
63 incl %edx
64 movb (%eax),%cl
65 testb %cl,%cl
66 jz L3
67 cmpb %cl,(%edx)
68 jne L3
69 incl %eax
70 incl %edx
71 movb (%eax),%cl
72 testb %cl,%cl
73 jz L3
74 cmpb %cl,(%edx)
75 jne L3
76 incl %eax
77 incl %edx
78 movb (%eax),%cl
79 testb %cl,%cl
80 jz L3
81 cmpb %cl,(%edx)
82 jne L3
83 incl %eax
84 incl %edx
85 movb (%eax),%cl
86 testb %cl,%cl
87 jz L3
88 cmpb %cl,(%edx)
89 je L1
90 .align 2, 0x90
91 L3: movzbl (%eax),%eax /* unsigned comparison */
92 movzbl (%edx),%edx
93 subl %edx,%eax
94 ret
95 #elif defined(__ppc__)
96 mr r5,r3
97 1: lbz r3,0(r5)
98 addi r5,r5,1
99 cmpwi cr1,r3,0
100 lbz r0,0(r4)
101 addi r4,r4,1
102 subf. r3,r0,r3
103 beqlr+ cr1
104 beq- 1b
105 blr
106 #else
107 #error strcmp is not defined for this architecture
108 #endif