https://github.com/akkartik/mu/blob/main/202write-int.subx
1
2
3 == code
4
5
6
7
8 write-int:
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 57/push-edi
16
17 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
18
19 8b/copy 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . .
20
21 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 8/disp8 .
22 7d/jump-if->= $write-int:abort/disp8
23 $write-int:to-stream:
24
25 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0xc/disp8 .
26 89/copy 1/mod/*+disp8 4/rm32/sib 7/base/edi 1/index/ecx . 0/r32/eax 0xc/disp8 .
27
28 81 0/subop/add 0/mod/indirect 7/rm32/edi . . . . . 4/imm32
29 $write-int:end:
30
31 5f/pop-to-edi
32 59/pop-to-ecx
33 58/pop-to-eax
34
35 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
36 5d/pop-to-ebp
37 c3/return
38
39 $write-int:abort:
40
41
42 68/push "write-int: out of space\n"/imm32
43 68/push 2/imm32/stderr
44
45 e8/call _write/disp32
46
47 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
48
49 bb/copy-to-ebx 1/imm32
50 e8/call syscall_exit/disp32
51
52
53 test-write-int-single:
54
55
56
57
58 68/push _test-stream/imm32
59
60 e8/call clear-stream/disp32
61
62 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
63
64
65 68/push 0x64636261/imm32
66 68/push _test-stream/imm32
67
68 e8/call write-int/disp32
69
70 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
71
72
73 68/push "F - test-write-int-single"/imm32
74 68/push "abcd"/imm32
75 68/push _test-stream/imm32
76
77 e8/call check-stream-equal/disp32
78
79 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
80
81 c3/return
82
83 test-write-byte-buffered-multiple:
84
85
86
87
88 68/push _test-stream/imm32
89
90 e8/call clear-stream/disp32
91
92 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
93
94
95 68/push 0x64636261/imm32
96 68/push _test-stream/imm32
97
98 e8/call write-int/disp32
99
100 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
101
102
103 68/push 0x68676665/imm32
104 68/push _test-stream/imm32
105
106 e8/call write-int/disp32
107
108 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
109
110
111 68/push "F - test-write-byte-buffered-multiple"/imm32
112 68/push "abcdefgh"/imm32
113 68/push _test-stream/imm32
114
115 e8/call check-stream-equal/disp32
116
117 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
118
119 c3/return
120
121