repo.or.cz
/
neatlibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
stdio: conversion specifiers should immediately follow length modifiers
[neatlibc.git]
/
x86
/
string.s
blob
215319cd499d5e6476dc5fd7af9829ff8d9aebc7
1
format ELF
2
3
public memcpy
4
memcpy
:
5
push esi
6
push edi
7
mov edi
, [
esp+
12
]
8
mov esi
, [
esp+
16
]
9
mov ecx
, [
esp+
20
]
10
mov eax
,
edi
11
cld
12
rep movsb
13
pop edi
14
pop esi
15
ret
16
17
public memmove
18
memmove
:
19
push esi
20
push edi
21
mov edi
, [
esp+
12
]
22
mov esi
, [
esp+
16
]
23
mov ecx
, [
esp+
20
]
24
cmp
edi
,
esi
25
jng
.usual
26
mov eax
,
esi
27
add
eax
,
ecx
28
cmp
edi
,
eax
29
jg
.usual
30
31
mov eax
,
edi
32
std
33
add
esi
,
ecx
34
add
edi
,
ecx
35
dec
esi
36
dec
edi
37
rep movsb
38
jmp
.ret
39
.usual:
40
mov eax
,
edi
41
cld
42
rep movsb
43
.ret:
44
pop edi
45
pop esi
46
ret
47
48
public memset
49
memset
:
50
push edi
51
mov edi
, [
esp+
8
]
52
mov eax
, [
esp+
12
]
53
mov ecx
, [
esp+
16
]
54
mov edx
,
edi
55
cld
56
rep stosb
57
pop edi
58
mov eax
,
edx
59
ret
60
61
public memchr
62
memchr
:
63
mov eax
, [
esp+
8
]
64
mov ecx
, [
esp+
12
]
65
push edi
66
mov edi
, [
esp+
8
]
67
test ecx
,
ecx
68
jz
.failed
69
cld
70
repnz scasb
71
jne
.failed
72
mov eax
,
edi
73
dec
eax
74
jmp
.ret
75
.failed:
76
xor
eax
,
eax
77
.ret:
78
pop edi
79
ret
80
81
public memcmp
82
memcmp
:
83
push esi
84
push edi
85
xor
eax
,
eax
86
mov esi
, [
esp+
12
]
87
mov edi
, [
esp+
16
]
88
mov ecx
, [
esp+
20
]
89
jecxz
.ret
90
91
cld
92
rep cmpsb
93
jz
.ret
94
sbb eax
,
eax
95
or
eax
,
1
96
.ret:
97
pop edi
98
pop esi
99
ret
100
101
public strlen
102
strlen
:
103
push edi
104
mov edi
, [
esp+
8
]
105
xor
eax
,
eax
106
mov ecx
, -
1
107
cld
108
repnz scasb
109
mov eax
,
ecx
110
not
eax
111
dec
eax
112
pop edi
113
ret
114
115
public memrchr
116
memrchr
:
117
mov eax
, [
esp+
8
]
118
mov ecx
, [
esp+
12
]
119
push edi
120
mov edi
, [
esp+
8
]
121
add
edi
,
ecx
122
dec
edi
123
test ecx
,
ecx
124
jz
.failed
125
std
126
repnz scasb
127
jne
.failed
128
mov eax
,
edi
129
inc eax
130
jmp
.ret
131
.failed:
132
xor
eax
,
eax
133
.ret:
134
pop edi
135
ret
136
137
public strchr
138
strchr
:
139
mov ecx
, [
esp+
4
]
140
mov edx
, [
esp+
8
]
141
.loop:
142
mov al
, [
ecx
]
143
cmp
al
,
dl
144
jz
.done
145
inc ecx
146
test al
,
al
147
jnz
.loop
148
xor
ecx
,
ecx
149
.done:
150
mov eax
,
ecx
151
ret
152
153
public strcmp
154
strcmp
:
155
mov ecx
, [
esp+
4
]
156
mov edx
, [
esp+
8
]
157
xor
eax
,
eax
158
.loop:
159
mov al
, [
ecx
]
160
cmp
al
, [
edx
]
161
jnz
.ret
162
inc edx
163
inc ecx
164
test al
,
al
165
jnz
.loop
166
ret
167
.ret:
168
movzx ecx
,
byte
[
edx
]
169
sub
eax
,
ecx
170
ret
171
172
public strcpy
173
strcpy
:
174
push edi
175
push esi
176
mov edx
, [
esp+
12
]
177
mov esi
, [
esp+
16
]
178
mov edi
,
edx
179
cld
180
.loop:
181
lodsb
182
stosb
183
or
al
,
al
184
jnz
.loop
185
pop esi
186
pop edi
187
mov eax
,
edx
188
ret
189
190
public strrchr
191
strrchr
:
192
push edi
193
mov edi
, [
esp+
8
]
194
mov ecx
, [
esp+
12
]
195
xor
edx
,
edx
196
dec
edi
197
.loop:
198
inc edi
199
mov al
, [
edi
]
200
test al
,
al
201
jz
.done
202
cmp
al
,
cl
203
jnz
.loop
204
mov edx
,
edi
205
jmp
.loop
206
.done:
207
mov eax
,
edx
208
pop edi
209
ret
210
211
public strncmp
212
strncmp
:
213
mov ecx
, [
esp+
4
]
214
mov edx
, [
esp+
8
]
215
xor
eax
,
eax
216
push edi
217
mov edi
, [
esp+
16
]
218
.loop:
219
test edi
,
edi
220
jz
.failed
221
mov al
, [
ecx
]
222
cmp
al
, [
edx
]
223
jnz
.ret
224
inc edx
225
inc ecx
226
dec
edi
227
test al
,
al
228
jnz
.loop
229
.failed:
230
xor
eax
,
eax
231
pop edi
232
ret
233
.ret:
234
movzx ecx
,
byte
[
edx
]
235
sub
eax
,
ecx
236
pop edi
237
ret