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