https://github.com/akkartik/mu/blob/master/subx/apps/subx-common.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-lesser $next-word:check1/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:check1:
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-not-equal $next-word:not-comment/disp8
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:not-comment:
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