@@ -57,8 +57,8 @@ function_prolog(__strchr440)
57
57
cmpwi r4,0
58
58
beq- char_is_null /* Search char is NULL, so do strlen op */
59
59
60
- xor r5,r5,r5 /* Clear total offset from start */
61
- neg r9,r3 /* get 2's complement of input address */
60
+ xor r5,r5,r5 /* Clear total offset from start */
61
+ neg r9,r3 /* get 2's complement of input address */
62
62
rlwinm. r7,r9,0 ,29 ,31 /* calc number of bytes to dword boundary */
63
63
beq- dwbndry /* if zero, then already on dword bndry */
64
64
@@ -74,30 +74,30 @@ bytebybyte:
74
74
75
75
dwbndry:
76
76
addi r6,0 ,8 /* Byte count of 8 in XER for 'load */
77
- mtxer r6 /* string' instruction later */
77
+ mtxer r6 /* string' instruction later */
78
78
79
79
rlwimi r4,r4,8 ,16 ,23 /* Set up 'c' in all bytes of word. */
80
- rlwimi. r4,r4,16 ,0 ,15 /* Remember 'c' in LSB of int */
80
+ rlwimi. r4,r4,16 ,0 ,15 /* Remember 'c' in LSB of int */
81
81
82
82
b again
83
83
84
84
comp: /* No NULL in eight bytes, look for 'c' */
85
85
86
- xor r6,r6,r4 /* XOR r4 & r6 to look for match */
87
- xor r7,r7,r4 /* XOR r4 & r7 to look for match */
86
+ xor r6,r6,r4 /* XOR r4 & r6 to look for match */
87
+ xor r7,r7,r4 /* XOR r4 & r7 to look for match */
88
88
89
- DLMZBDOT(0 ,6 ,7 ) /* Check for hole created by match */
89
+ DLMZBDOT(0 ,6 ,7 ) /* Check for hole created by match */
90
90
91
- add r5,r5,r0 /* Update total offset with 1-8 */
91
+ add r5,r5,r0 /* Update total offset with 1-8 */
92
92
93
- bne- found /* If no hole, fall through and get next 8 */
94
- /* bytes, otherwise, go to logic to handle */
95
- /* 8 bytes w/ match */
93
+ bne- found /* If no hole, fall through and get next 8 */
94
+ /* bytes, otherwise, go to logic to handle */
95
+ /* 8 bytes w/ match */
96
96
97
97
again: /* New 8 bytes, look for NULL first */
98
98
99
99
lswx r6,r3,r5 /* Load r6/r7 from r3 src + r5 offset */
100
- /* from the start */
100
+ /* from the start */
101
101
DLMZBDOT(12 ,6 ,7 ) /* Look for NULL in these current 8 bytes */
102
102
beq+ comp /* If no NULL, search 8 bytes for 'c' */
103
103
@@ -107,15 +107,13 @@ again: /* New 8 bytes, look for NULL first */
107
107
*/
108
108
109
109
xor r6,r6,r4 /* XOR r4 & r6 to look for match */
110
- xor r7,r7,r4 /* XOR r4 & r7 to look for match */
110
+ xor r7,r7,r4 /* XOR r4 & r7 to look for match */
111
111
112
- DLMZBDOT(0 ,6 ,7 ) /* Check for hole created by match */
112
+ DLMZBDOT(0 ,6 ,7 ) /* Check for hole created by match */
113
113
114
- cmplw r0,r12 /* Was there a match before the NULL? */
115
-
116
- bge ret_null /* If not, return NULL */
117
-
118
- add r5,r5,r0 /* Else, update the offset from the start */
114
+ cmplw r0,r12 /* Was there a match before the NULL? */
115
+ bge ret_null /* If not, return NULL */
116
+ add r5,r5,r0 /* Else, update the offset from the start */
119
117
120
118
/*
121
119
* Here we know the string is not ending, but we found a match in
@@ -126,19 +124,19 @@ again: /* New 8 bytes, look for NULL first */
126
124
found:
127
125
128
126
addi r5,r5,-1
129
- add r3,r3,r5 /* Return string start addr + offset to 'c'*/
127
+ add r3,r3,r5 /* Return string start addr + offset to 'c'*/
130
128
blr
131
129
132
130
ret_null:
133
131
134
- xor r3,r3,r3 /* Return NULL since no match found */
132
+ xor r3,r3,r3 /* Return NULL since no match found */
135
133
blr
136
134
137
- char_is_null: /* Since search char is NULL, we basically */
138
- /* do a strlen operation */
135
+ char_is_null: /* Since search char is NULL, we basically */
136
+ /* do a strlen operation */
139
137
140
- xor r12,r12,r12 /* Clear total offset from the start */
141
- neg r9,r3 /* get 2's complement of input address */
138
+ xor r12,r12,r12 /* Clear total offset from the start */
139
+ neg r9,r3 /* get 2's complement of input address */
142
140
rlwinm. r7,r9,0 ,29 ,31 /* calc number of bytes to dword boundary */
143
141
beq- s_dwbndry /* if zero, then already on dword bndry */
144
142
@@ -152,45 +150,44 @@ s_bytebybyte:
152
150
153
151
s_dwbndry:
154
152
rlwinm. r7,r9,29 ,30 ,31 /* calc # of dwords to quad word bndry */
155
- beq s_qwbndry /* if zero, then already on qword bndry */
156
- addi r7,0 ,8 /* Byte count of 8 into XER for 'load */
157
- /* string' instruction later */
158
- mtxer r7 /* Load count for 'load string' */
159
- lswx r6,r3,r12 /* Load r6-r7 from r3 src + r12 offset */
153
+ beq s_qwbndry /* if zero, then already on qword bndry */
154
+ addi r7,0 ,8 /* Byte count of 8 into XER for 'load */
155
+ /* string' instruction later */
156
+ mtxer r7 /* Load count for 'load string' */
157
+ lswx r6,r3,r12 /* Load r6-r7 from r3 src + r12 offset */
160
158
DLMZBDOT(11 ,6 ,7 ) /* Look for NULL in these 8 bytes */
161
- add r12,r12,r11 /* Bump the offset from the start */
162
- bne- s_found /* If NULL found, done; else keep looking */
159
+ add r12,r12,r11 /* Bump the offset from the start */
160
+ bne- s_found /* If NULL found, done; else keep looking */
163
161
164
162
s_qwbndry:
165
163
166
- addi r5,0 ,16 /* Byte count of 16 into XER for 'load */
167
- /* string' instruction later */
164
+ addi r5,0 ,16 /* Byte count of 16 into XER for 'load */
165
+ /* string' instruction later */
168
166
169
167
s_again: /* New 16 bytes, look for NULL */
170
168
171
- mtxer r5 /* Load count for 'load string' */
172
- lswx r6,r3,r12 /* Load r6-r9 from r3 src + r12 offset */
173
- /* from the start */
169
+ mtxer r5 /* Load count for 'load string' */
170
+ lswx r6,r3,r12 /* Load r6-r9 from r3 src + r12 offset */
171
+ /* from the start */
174
172
DLMZBDOT(11 ,6 ,7 ) /* Look for NULL in these first 8 bytes */
175
173
176
- add r12,r12,r11 /* Bump the offset from the start */
174
+ add r12,r12,r11 /* Bump the offset from the start */
177
175
178
- bne- s_found /* If no NULL in first 8 bytes, fall */
179
- /* through and test next 8 bytes, else, */
180
- /* we're done */
176
+ bne- s_found /* If no NULL in first 8 bytes, fall */
177
+ /* through and test next 8 bytes, else, */
178
+ /* we're done */
181
179
182
- DLMZBDOT(11 ,8 ,9 ) /* Look for NULL in these next 8 bytes */
180
+ DLMZBDOT(11 ,8 ,9 ) /* Look for NULL in these next 8 bytes */
183
181
184
- add r12,r12,r11 /* Bump the offset from the start */
182
+ add r12,r12,r11 /* Bump the offset from the start */
185
183
186
- beq+ s_again /* If no NULL, grab next 16 bytes, else, */
187
- /* we're done. */
184
+ beq+ s_again /* If no NULL, grab next 16 bytes, else, */
185
+ /* we're done. */
188
186
s_found:
189
187
190
188
addi r12,r12,-1 /* Compensate for NULL */
189
+ add r3,r12,r3 /* Add returned length to string pointer */
191
190
192
- add r3,r12,r3 /* Add returned length to string pointer */
193
-
194
191
blr
195
192
196
193
function_epilog(__strchr440)
0 commit comments