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