https://github.com/akkartik/mu/blob/main/linux/115write-byte.subx
1
2
3
4
5
6
7 == data
8
9
10 Stdout:
11
12 1/imm32
13 $Stdout->buffer:
14
15
16 0/imm32
17
18 0/imm32
19
20 8/imm32
21
22 00 00 00 00 00 00 00 00
23
24
25
26
27 == code
28
29
30
31
32
33 write-byte-buffered:
34
35 55/push-ebp
36 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
37
38 51/push-ecx
39 57/push-edi
40
41 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
42
43 8b/copy 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 4/disp8 .
44
45 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 0xc/disp8 .
46 7c/jump-if-< $write-byte-buffered:to-stream/disp8
47
48
49 57/push-edi
50
51 e8/call flush/disp32
52
53 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
54
55
56 8d/copy-address 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 4/disp8 .
57 50/push-eax
58
59 e8/call clear-stream/disp32
60
61 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
62
63 31/xor 3/mod/direct 1/rm32/ecx . . . 1/r32/ecx . .
64 $write-byte-buffered:to-stream:
65
66
67 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
68 8a/copy-byte 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/AL 0xc/disp8 .
69 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/edi 1/index/ecx . 0/r32/AL 0x10/disp8 .
70
71 ff 0/subop/increment 1/mod/*+disp8 7/rm32/edi . . . . 4/disp8 .
72 $write-byte-buffered:end:
73
74 5f/pop-to-edi
75 59/pop-to-ecx
76
77 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
78 5d/pop-to-ebp
79 c3/return
80
81 flush:
82
83 55/push-ebp
84 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
85
86 50/push-eax
87 51/push-ecx
88
89 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 8/disp8 .
90
91
92 8d/copy-address 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
93 51/push-ecx
94 ff 6/subop/push 0/mod/indirect 0/rm32/eax . . . . . .
95
96 e8/call write-stream/disp32
97
98 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
99 $flush:end:
100
101 59/pop-to-ecx
102 58/pop-to-eax
103
104 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
105 5d/pop-to-ebp
106 c3/return
107
108 test-write-byte-buffered-single:
109
110
111
112
113 68/push _test-stream/imm32
114
115 e8/call clear-stream/disp32
116
117 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
118
119
120 68/push $_test-buffered-file->buffer/imm32
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 68/push $_test-buffered-file->buffer/imm32
165
166 e8/call clear-stream/disp32
167
168 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
169
170
171
172 68/push "abcdef"/imm32
173 68/push $_test-buffered-file->buffer/imm32
174
175 e8/call write/disp32
176
177 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
178
179
180 68/push 0x67/imm32
181 68/push _test-buffered-file/imm32
182
183 e8/call write-byte-buffered/disp32
184
185 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
186
187
188 68/push _test-buffered-file/imm32
189
190 e8/call flush/disp32
191
192 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
193
194
195 68/push "F - test-write-byte-buffered-multiple-flushes"/imm32
196 68/push "abcdefg"/imm32
197 68/push _test-stream/imm32
198
199 e8/call check-stream-equal/disp32
200
201 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
202
203 c3/return
204
205
206
207
208 append-byte:
209
210 55/push-ebp
211 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
212
213 50/push-eax
214 51/push-ecx
215 57/push-edi
216
217 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
218
219 8b/copy 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . .
220
221 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 8/disp8 .
222 7d/jump-if->= $append-byte:abort/disp8
223 $append-byte:to-stream:
224
225
226 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
227 8a/copy-byte 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/AL 0xc/disp8 .
228 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/edi 1/index/ecx . 0/r32/AL 0xc/disp8 .
229
230 ff 0/subop/increment 0/mod/indirect 7/rm32/edi . . . . . .
231 $append-byte:end:
232
233 5f/pop-to-edi
234 59/pop-to-ecx
235 58/pop-to-eax
236
237 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
238 5d/pop-to-ebp
239 c3/return
240
241 $append-byte:abort:
242
243
244 68/push "append-byte: out of space\n"/imm32
245 68/push 2/imm32/stderr
246
247 e8/call _write/disp32
248
249 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
250
251 bb/copy-to-ebx 1/imm32
252 e8/call syscall_exit/disp32
253
254
255 test-append-byte-single:
256
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
267 68/push 0x41/imm32
268 68/push _test-stream/imm32
269
270 e8/call append-byte/disp32
271
272 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
273
274
275 68/push "F - test-append-byte-single"/imm32
276 68/push "A"/imm32
277 68/push _test-stream/imm32
278
279 e8/call check-stream-equal/disp32
280
281 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
282
283 c3/return
284
285 == data
286
287 _test-output-stream:
288
289 0/imm32
290
291 0/imm32
292
293 0x800/imm32
294
295 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
296 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
297 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
331 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
332 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
333 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
334 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
335 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
336 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
337 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
338 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
339 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
341 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
342 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
343 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
344 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
345 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
346 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
347 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
348 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
349 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
351 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
361 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
362 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
363 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
364 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
365 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
366 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
367 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
368 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
369 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
371 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
372 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
373 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
374 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
375 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
376 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
377 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
378 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
379 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
381 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
382 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
383 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
384 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
385 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
386 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
387 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
388 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
389 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
391 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
392 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
393 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
394 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
395 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
396 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
397 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
398 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
399 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
401 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
402 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
403 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
404 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
405 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
406 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
407 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
408 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
409 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
411 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
412 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
413 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
414 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
415 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
416 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
417 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
418 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
419 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
421 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
422 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
423
424
425 _test-output-buffered-file:
426
427 _test-output-stream/imm32
428 $_test-output-buffered-file->buffer:
429
430 0/imm32
431
432 0/imm32
433
434 6/imm32
435
436 00 00 00 00 00 00
437
438 _test-error-stream:
439
440 0/imm32
441
442 0/imm32
443
444 0x100/imm32
445
446 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
447 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
448 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
449 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
451 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
452 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
453 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
454 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
455 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
456 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
457 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
458 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
459 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
461 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
462
463
464 _test-error-buffered-file:
465
466 _test-error-stream/imm32
467 $_test-error-buffered-file->buffer:
468
469 0/imm32
470
471 0/imm32
472
473 6/imm32
474
475 00 00 00 00 00 00
476
477