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