https://github.com/akkartik/mu/blob/main/linux/108write.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 == code
19
20
21
22
23
24 write:
25
26 55/push-ebp
27 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
28
29 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 0/imm32
30 74/jump-if-= $write:end/disp8
31
32 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 0x08000000/imm32
33 73/jump-if-addr>= $write:fake/disp8
34
35 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
36 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
37
38 e8/call _write/disp32
39
40 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
41 eb/jump $write:end/disp8
42 $write:fake:
43
44
45 50/push-eax
46 51/push-ecx
47 52/push-edx
48 53/push-ebx
49
50 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 1/r32/ecx 8/disp8 .
51
52 8b/copy 0/mod/indirect 1/rm32/ecx . . . 2/r32/edx . .
53
54 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 3/r32/ebx 8/disp8 .
55
56
57 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
58
59 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 3/index/ebx . 3/r32/ebx 0xc/disp8 .
60 53/push-ebx
61
62 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 2/index/edx . 3/r32/ebx 0xc/disp8 .
63 53/push-ebx
64
65 e8/call _append-3/disp32
66
67 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
68
69 01/add 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
70
71 5b/pop-to-ebx
72 5a/pop-to-edx
73 59/pop-to-ecx
74 58/pop-to-eax
75 $write:end:
76
77 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
78 5d/pop-to-ebp
79 c3/return
80
81 test-write-single:
82
83
84 68/push _test-stream/imm32
85
86 e8/call clear-stream/disp32
87
88 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
89
90
91 68/push "Ab"/imm32
92 68/push _test-stream/imm32
93
94 e8/call write/disp32
95
96 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
97
98
99 68/push "F - test-write-single"/imm32
100 68/push 0x006241/imm32/Ab
101
102 b8/copy-to-eax _test-stream/imm32
103 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 0xc/disp8 .
104
105 e8/call check-ints-equal/disp32
106
107 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
108
109 c3/return
110
111 test-write-appends:
112
113
114 68/push _test-stream/imm32
115
116 e8/call clear-stream/disp32
117
118 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
119
120
121 68/push "C"/imm32
122 68/push _test-stream/imm32
123
124 e8/call write/disp32
125
126 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
127
128
129 68/push "D"/imm32
130 68/push _test-stream/imm32
131
132 e8/call write/disp32
133
134 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
135
136
137 68/push "F - test-write-appends"/imm32
138 68/push 0x00004443/imm32/C-D
139
140 b8/copy-to-eax _test-stream/imm32
141 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 0xc/disp8 .
142
143 e8/call check-ints-equal/disp32
144
145 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
146
147 c3/return
148
149 == data
150
151 _test-stream:
152
153 0/imm32
154
155 0/imm32
156
157 0x10/imm32
158
159 00 00 00 00 00 00 00 00
160 00 00 00 00 00 00 00 00
161
162