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