https://github.com/akkartik/mu/blob/master/076next-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 68/push 0x20/imm32/space
26 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
27
28 e8/call skip-chars-matching/disp32
29
30 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/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 89/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
61
62 eb/jump $next-word:end/disp8
63 $next-word:regular-word:
64
65
66 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
67
68 e8/call skip-chars-not-matching-whitespace/disp32
69
70 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
71
72 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
73 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
74 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
75 $next-word:end:
76
77 5f/pop-to-edi
78 5e/pop-to-esi
79 59/pop-to-ecx
80 58/pop-to-eax
81
82 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
83 5d/pop-to-ebp
84 c3/return
85
86 test-next-word:
87
88 55/push-ebp
89 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
90
91
92
93 68/push _test-stream/imm32
94
95 e8/call clear-stream/disp32
96
97 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
98
99 68/push 0/imm32/end
100 68/push 0/imm32/start
101 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
102
103
104 68/push " ab"/imm32
105 68/push _test-stream/imm32
106
107 e8/call write/disp32
108
109 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
110
111
112 51/push-ecx
113 68/push _test-stream/imm32
114
115 e8/call next-word/disp32
116
117 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
118
119
120
121 68/push "F - test-next-word: start"/imm32
122 68/push 0xe/imm32
123
124 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
125 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
126 50/push-eax
127
128 e8/call check-ints-equal/disp32
129
130 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
131
132
133
134 68/push "F - test-next-word: end"/imm32
135 68/push 0x10/imm32
136
137 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
138 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
139 50/push-eax
140
141 e8/call check-ints-equal/disp32
142
143 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
144
145 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
146 5d/pop-to-ebp
147 c3/return
148
149 test-next-word-returns-whole-comment:
150
151 55/push-ebp
152 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
153
154
155
156 68/push _test-stream/imm32
157
158 e8/call clear-stream/disp32
159
160 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
161
162 68/push 0/imm32/end
163 68/push 0/imm32/start
164 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
165
166
167 68/push " # a"/imm32
168 68/push _test-stream/imm32
169
170 e8/call write/disp32
171
172 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
173
174
175 51/push-ecx
176 68/push _test-stream/imm32
177
178 e8/call next-word/disp32
179
180 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
181
182
183
184 68/push "F - test-next-word-returns-whole-comment: start"/imm32
185 68/push 0xe/imm32
186
187 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
188 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
189 50/push-eax
190
191 e8/call check-ints-equal/disp32
192
193 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
194
195
196
197 68/push "F - test-next-word-returns-whole-comment: end"/imm32
198 68/push 0x11/imm32
199
200 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
201 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-stream/imm32
202 50/push-eax
203
204 e8/call check-ints-equal/disp32
205
206 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
207
208 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
209 5d/pop-to-ebp
210 c3/return
211
212 test-next-word-returns-empty-string-on-eof:
213
214 55/push-ebp
215 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
216
217
218
219 68/push _test-stream/imm32
220
221 e8/call clear-stream/disp32
222
223 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
224
225 68/push 0/imm32/end
226 68/push 0/imm32/start
227 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
228
229
230
231 51/push-ecx
232 68/push _test-stream/imm32
233
234 e8/call next-word/disp32
235
236 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
237
238
239 68/push "F - test-next-word-returns-empty-string-on-eof"/imm32
240 68/push 0/imm32
241
242 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
243 2b/subtract 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
244 50/push-eax
245
246 e8/call check-ints-equal/disp32
247
248 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
249
250 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
251 5d/pop-to-ebp
252 c3/return