OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [i386/] [strchr.S] - Blame information for rev 301

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * ====================================================
3
 * Copyright (C) 1998, 2002, 2008 by Red Hat Inc. All rights reserved.
4
 *
5
 * Permission to use, copy, modify, and distribute this
6
 * software is freely granted, provided that this notice
7
 * is preserved.
8
 * ====================================================
9
 */
10
 
11
        #include "i386mach.h"
12
 
13
        .global SYM (strchr)
14
       SOTYPE_FUNCTION(strchr)
15
 
16
SYM (strchr):
17
 
18
        pushl ebp
19
        movl esp,ebp
20
        pushl edi
21
        pushl ebx
22
        xorl ebx,ebx
23
        movl 8(ebp),edi
24
        addb 12(ebp),bl
25
 
26
#ifndef __OPTIMIZE_SIZE__
27
/* Special case strchr(p,0).  */
28
        je L25
29
 
30
/* Do byte-wise checks until string is aligned.  */
31
        test $3,edi
32
        je L5
33
        movl edi,eax
34
        movb (eax),cl
35
        testb cl,cl
36
        je L14
37
        cmpb bl,cl
38
        je L19
39
        incl edi
40
 
41
        test $3,edi
42
        je L5
43
        movl edi,eax
44
        movb (eax),cl
45
        testb cl,cl
46
        je L14
47
        cmpb bl,cl
48
        je L19
49
        incl edi
50
 
51
        test $3,edi
52
        je L5
53
        movl edi,eax
54
        movb (eax),cl
55
        testb cl,cl
56
        je L14
57
        cmpb bl,cl
58
        je L19
59
        incl edi
60
 
61
/* create 4 byte mask which is just the desired byte repeated 4 times */
62
L5:
63
        movl ebx,ecx
64
        sall $8,ebx
65
        subl $4,edi
66
        orl ecx,ebx
67
        movl ebx,edx
68
        sall $16,ebx
69
        orl edx,ebx
70
 
71
/* loop performing 4 byte mask checking for 0 byte or desired byte */
72
        .p2align 4,,7
73
L10:
74
        addl $4,edi
75
        movl (edi),ecx
76
        leal -16843009(ecx),edx
77
        movl ecx,eax
78
        notl eax
79
        andl eax,edx
80
        testl $-2139062144,edx
81
        jne L9
82
 
83
        xorl ebx,ecx
84
        leal -16843009(ecx),edx
85
        notl ecx
86
        andl ecx,edx
87
        testl $-2139062144,edx
88
        je L10
89
#endif /* not __OPTIMIZE_SIZE__ */
90
 
91
/* loop while (*s && *s++ != c) */
92
L9:
93
        leal -1(edi),eax
94
        .p2align 4,,7
95
L15:
96
        incl eax
97
        movb (eax),dl
98
        testb dl,dl
99
        je L14
100
        cmpb bl,dl
101
        jne L15
102
 
103
L14:
104
/*  if (*s == c) return address otherwise return NULL */
105
        cmpb bl,(eax)
106
        je L19
107
        xorl eax,eax
108
 
109
L19:
110
        leal -8(ebp),esp
111
        popl ebx
112
        popl edi
113
        leave
114
        ret
115
 
116
#ifndef __OPTIMIZE_SIZE__
117
/* Special case strchr(p,0).  */
118
#if 0
119
        /* Hideous performance on modern machines.  */
120
L25:
121
        cld
122
        movl $-1,ecx
123
        xor eax,eax
124
        repnz
125
        scasb
126
        leal -1(edi),eax
127
        jmp L19
128
#endif
129
L25:
130
/* Do byte-wise checks until string is aligned.  */
131
        test $3,edi
132
        je L26
133
        movl edi,eax
134
        movb (eax),cl
135
        testb cl,cl
136
        je L19
137
        incl edi
138
 
139
        test $3,edi
140
        je L26
141
        movl edi,eax
142
        movb (eax),cl
143
        testb cl,cl
144
        je L19
145
        incl edi
146
 
147
        test $3,edi
148
        je L26
149
        movl edi,eax
150
        movb (eax),cl
151
        testb cl,cl
152
        je L19
153
        incl edi
154
 
155
L26:
156
        subl $4,edi
157
 
158
/* loop performing 4 byte mask checking for desired 0 byte */
159
        .p2align 4,,7
160
L27:
161
        addl $4,edi
162
        movl (edi),ecx
163
        leal -16843009(ecx),edx
164
        movl ecx,eax
165
        notl eax
166
        andl eax,edx
167
        testl $-2139062144,edx
168
        je L27
169
 
170
        jmp L9
171
 
172
#endif /* !__OPTIMIZE_SIZE__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.