https://github.com/akkartik/mu/blob/main/135next-word-or-string.subx
1 == code
2
3
4
5
6
7
8 next-word-or-string:
9
10 55/push-ebp
11 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
12
13 50/push-eax
14 51/push-ecx
15 56/push-esi
16 57/push-edi
17
18 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
19
20 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
21
22
23 68/push 0x20/imm32/space
24 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
25
26 e8/call skip-chars-matching/disp32
27
28 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
29 $next-word-or-string:check0:
30
31
32 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
33
34 3b/compare 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
35 7c/jump-if-< $next-word-or-string:check-for-comment/disp8
36
37 c7 0/subop/copy 0/mod/direct 7/rm32/edi . . . . . 0/imm32
38 c7 0/subop/copy 1/mod/*+disp8 7/rm32/edi . . . . 4/disp8 0/imm32
39 eb/jump $next-word-or-string:end/disp8
40 $next-word-or-string:check-for-comment:
41
42 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
43 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
44 89/copy 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . .
45
46
47 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
48 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
49
50 3d/compare-eax-and 0x23/imm32/pound
51 75/jump-if-!= $next-word-or-string:check-for-string-literal/disp8
52 $next-word-or-string:comment:
53
54 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
55 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
56 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
57
58 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
59 89/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
60
61 eb/jump $next-word-or-string:end/disp8
62 $next-word-or-string:check-for-string-literal:
63
64
65 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
66 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
67
68 3d/compare-eax-and 0x22/imm32/dquote
69 75/jump-if-!= $next-word-or-string:regular-word/disp8
70 $next-word-or-string:string-literal:
71
72
73 56/push-esi
74
75 e8/call skip-string/disp32
76
77 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
78
79 $next-word-or-string:regular-word:
80
81
82 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
83
84 e8/call skip-chars-not-matching-whitespace/disp32
85
86 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
87
88 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
89 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
90 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
91 $next-word-or-string:end:
92
93 5f/pop-to-edi
94 5e/pop-to-esi
95 59/pop-to-ecx
96 58/pop-to-eax
97
98 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
99 5d/pop-to-ebp
100 c3/return
101
102 test-next-word-or-string:
103
104 55/push-ebp
105 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
106
107
108
109 68/push _test-input-stream/imm32
110
111 e8/call clear-stream/disp32
112
113 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
114
115 68/push 0/imm32/end
116 68/push 0/imm32/start
117 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
118
119
120 68/push " ab"/imm32
121 68/push _test-input-stream/imm32
122
123 e8/call write/disp32
124
125 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
126
127
128 51/push-ecx
129 68/push _test-input-stream/imm32
130
131 e8/call next-word-or-string/disp32
132
133 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
134
135
136 68/push "F - test-next-word-or-string/updates-stream-read-correctly"/imm32
137 68/push 4/imm32
138 b8/copy-to-eax _test-input-stream/imm32
139 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 4/disp8 .
140
141 e8/call check-ints-equal/disp32
142
143 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
144
145
146
147 68/push "F - test-next-word-or-string: start"/imm32
148 68/push 0xe/imm32
149
150 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
151 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
152 50/push-eax
153
154 e8/call check-ints-equal/disp32
155
156 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
157
158
159
160 68/push "F - test-next-word-or-string: end"/imm32
161 68/push 0x10/imm32
162
163 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
164 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
165 50/push-eax
166
167 e8/call check-ints-equal/disp32
168
169 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
170
171 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
172 5d/pop-to-ebp
173 c3/return
174
175 test-next-word-or-string-returns-whole-comment:
176
177 55/push-ebp
178 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
179
180
181
182 68/push _test-input-stream/imm32
183
184 e8/call clear-stream/disp32
185
186 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
187
188 68/push 0/imm32/end
189 68/push 0/imm32/start
190 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
191
192
193 68/push " # a"/imm32
194 68/push _test-input-stream/imm32
195
196 e8/call write/disp32
197
198 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
199
200
201 51/push-ecx
202 68/push _test-input-stream/imm32
203
204 e8/call next-word-or-string/disp32
205
206 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
207
208
209 68/push "F - test-next-word-or-string-returns-whole-comment/updates-stream-read-correctly"/imm32
210 68/push 5/imm32
211 b8/copy-to-eax _test-input-stream/imm32
212 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 4/disp8 .
213
214 e8/call check-ints-equal/disp32
215
216 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
217
218
219
220 68/push "F - test-next-word-or-string-returns-whole-comment: start"/imm32
221 68/push 0xe/imm32
222
223 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
224 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
225 50/push-eax
226
227 e8/call check-ints-equal/disp32
228
229 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
230
231
232
233 68/push "F - test-next-word-or-string-returns-whole-comment: end"/imm32
234 68/push 0x11/imm32
235
236 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
237 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
238 50/push-eax
239
240 e8/call check-ints-equal/disp32
241
242 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
243
244 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
245 5d/pop-to-ebp
246 c3/return
247
248 test-next-word-or-string-returns-empty-slice-on-eof:
249
250 55/push-ebp
251 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
252
253
254
255 68/push _test-input-stream/imm32
256
257 e8/call clear-stream/disp32
258
259 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
260
261 68/push 0/imm32/end
262 68/push 0/imm32/start
263 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
264
265
266
267 51/push-ecx
268 68/push _test-input-stream/imm32
269
270 e8/call next-word-or-string/disp32
271
272 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
273
274
275 68/push "F - test-next-word-or-string-returns-empty-string-on-eof"/imm32
276 68/push 0/imm32
277
278 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
279 2b/subtract 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
280 50/push-eax
281
282 e8/call check-ints-equal/disp32
283
284 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
285
286 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
287 5d/pop-to-ebp
288 c3/return
289
290 test-next-word-or-string-returns-string-literal:
291
292 55/push-ebp
293 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
294
295
296
297 68/push _test-input-stream/imm32
298
299 e8/call clear-stream/disp32
300
301 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
302
303 68/push 0/imm32/end
304 68/push 0/imm32/start
305 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
306
307
308 68/push " \"a b\"/imm32 "/imm32
309 68/push _test-input-stream/imm32
310
311 e8/call write/disp32
312
313 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
314
315
316 51/push-ecx
317 68/push _test-input-stream/imm32
318
319 e8/call next-word-or-string/disp32
320
321 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
322
323
324
325 68/push "F - test-next-word-or-string-returns-string-literal: start"/imm32
326 68/push 0xd/imm32
327
328 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
329 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
330 50/push-eax
331
332 e8/call check-ints-equal/disp32
333
334 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
335
336
337
338 68/push "F - test-next-word-or-string-returns-string-literal: end"/imm32
339 68/push 0x18/imm32
340
341 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
342 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
343 50/push-eax
344
345 e8/call check-ints-equal/disp32
346
347 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
348
349 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
350 5d/pop-to-ebp
351 c3/return
352
353 test-next-word-or-string-returns-string-with-escapes:
354
355 55/push-ebp
356 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
357
358
359
360 68/push _test-input-stream/imm32
361
362 e8/call clear-stream/disp32
363
364 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
365
366 68/push 0/imm32/end
367 68/push 0/imm32/start
368 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
369
370
371 68/push " \"a\\\"b\"/x"/imm32
372 68/push _test-input-stream/imm32
373
374 e8/call write/disp32
375
376 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
377
378
379 51/push-ecx
380 68/push _test-input-stream/imm32
381
382 e8/call next-word-or-string/disp32
383
384 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
385
386
387
388 68/push "F - test-next-word-or-string-returns-string-with-escapes: start"/imm32
389 68/push 0xd/imm32
390
391 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
392 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
393 50/push-eax
394
395 e8/call check-ints-equal/disp32
396
397 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
398
399
400
401 68/push "F - test-next-word-or-string-returns-string-with-escapes: end"/imm32
402 68/push 0x15/imm32
403
404 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
405 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
406 50/push-eax
407
408 e8/call check-ints-equal/disp32
409
410 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
411
412 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
413 5d/pop-to-ebp
414 c3/return
415
416