https://github.com/akkartik/mu/blob/master/094next-word-or-string.subx
1 == code
2
3
4
5
6
7
8 next-word-or-string:
9
10 55/push-ebp
11 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
12
13 50/push-eax
14 51/push-ecx
15 56/push-esi
16 57/push-edi
17
18 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
19
20 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
21
22
23 68/push 0x20/imm32/space
24 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
25
26 e8/call skip-chars-matching/disp32
27
28 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
29 $next-word-or-string:check0:
30
31
32 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
33
34 3b/compare 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
35 7c/jump-if-lesser $next-word-or-string:check-for-comment/disp8
36
37 c7 0/subop/copy 0/mod/direct 7/rm32/edi . . . . . 0/imm32
38 c7 0/subop/copy 1/mod/*+disp8 7/rm32/edi . . . . 4/disp8 0/imm32
39 eb/jump $next-word-or-string:end/disp8
40 $next-word-or-string:check-for-comment:
41
42 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
43 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
44 89/copy 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . .
45
46
47 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
48 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
49
50 3d/compare-eax-and 0x23/imm32/pound
51 75/jump-if-not-equal $next-word-or-string:check-for-string-literal/disp8
52 $next-word-or-string:comment:
53
54 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
55 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
56 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
57
58 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
59 89/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
60
61 eb/jump $next-word-or-string:end/disp8
62 $next-word-or-string:check-for-string-literal:
63
64
65 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
66 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
67
68 3d/compare-eax-and 0x22/imm32/dquote
69 75/jump-if-not-equal $next-word-or-string:regular-word/disp8
70 $next-word-or-string:string-literal:
71
72
73 56/push-esi
74
75 e8/call skip-string/disp32
76
77 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
78
79 $next-word-or-string:regular-word:
80
81
82 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
83
84 e8/call skip-chars-not-matching-whitespace/disp32
85
86 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
87
88 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
89 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/eax 0xc/disp8 .
90 89/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
91 $next-word-or-string:end:
92
93 5f/pop-to-edi
94 5e/pop-to-esi
95 59/pop-to-ecx
96 58/pop-to-eax
97
98 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
99 5d/pop-to-ebp
100 c3/return
101
102 test-next-word-or-string:
103
104 55/push-ebp
105 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
106
107
108
109 68/push _test-input-stream/imm32
110
111 e8/call clear-stream/disp32
112
113 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
114
115 68/push 0/imm32/end
116 68/push 0/imm32/start
117 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
118
119
120 68/push " ab"/imm32
121 68/push _test-input-stream/imm32
122
123 e8/call write/disp32
124
125 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
126
127
128 51/push-ecx
129 68/push _test-input-stream/imm32
130
131 e8/call next-word-or-string/disp32
132
133 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
134
135
136 68/push "F - test-next-word-or-string/updates-stream-read-correctly"/imm32
137 68/push 4/imm32
138 b8/copy-to-eax _test-input-stream/imm32
139 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 4/disp8 .
140
141 e8/call check-ints-equal/disp32
142
143 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
144
145
146
147 68/push "F - test-next-word-or-string: start"/imm32
148 68/push 0xe/imm32
149
150 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
151 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
152 50/push-eax
153
154 e8/call check-ints-equal/disp32
155
156 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
157
158
159
160 68/push "F - test-next-word-or-string: end"/imm32
161 68/push 0x10/imm32
162
163 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
164 81 5/subop/subtract 3/mod/direct 0/rm32/eax . . . . . _test-input-stream/imm32
165 50/push-eax
166
167 e8/call check-ints-equal/disp32
168
169 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
170
171 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
172 5d/pop-to-ebp
173 c3/return
174
175 test-next-word-or-string-returns-whole-comment:
176
177 55/push-ebp
178 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
179
180
181
182 68/push _test-input-stream/imm32
183
184 e8/call clear-stream/disp32
185
186 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
187
188 68/push 0/imm32/end
189 68/push 0/imm32/start
190 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
191
192
193 68/push " # a"/imm32
194 68/push _test-input-stream/imm32
195
196 e8/call write/disp32
197
198 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
199
200
201 51/push-ecx
202 68/push _test-input-stream/imm32
203
204 e8/call next-word-or-string/disp32
205
206 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
207
208
209 68/push "F - test-next-word-or-string-returns-whole-comment/updates-stream-read-correctly"/imm32
210 68/push 5/imm32
211 b8/copy-to-eax _test-input-stream/imm32
212 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 4/disp8 .
213
214 e8/call check-ints-equal/disp32
215
216 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32