https://github.com/akkartik/mu/blob/master/subx/060write-stream.subx
1
2
3 == code
4
5
6
7
8
9
10
11
12
13
14
15
16 e8/call run-tests/disp32
17
18 8b/copy 0/mod/indirect 5/rm32/.disp32 3/r32/EBX Num-test-failures/disp32
19 b8/copy-to-EAX 1/imm32
20 cd/syscall 0x80/imm8
21
22 write-stream:
23
24 55/push-EBP
25 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
26
27 81 7/subop/compare 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 0x08000000/imm32
28 7d/jump-if-greater-or-equal $write-stream:fake/disp8
29
30 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0xc/disp8
31 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8
32
33 e8/call _write-stream/disp32
34
35 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
36 eb/jump $write-stream:end/disp8
37 $write-stream:fake:
38
39
40 50/push-EAX
41 56/push-ESI
42 57/push-EDI
43
44 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 8/disp8
45
46 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 7/r32/EDI 0xc/disp8
47
48
49 8b/copy 0/mod/indirect 7/rm32/EDI 0/r32/EAX
50 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 0/index/EAX 0/r32/EAX 0xc/disp8
51 50/push-EAX
52
53 8b/copy 1/mod/*+disp8 7/rm32/EDI 0/r32/EAX 4/disp8
54 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 0/index/EAX 0/r32/EAX 0xc/disp8
55 50/push-EAX
56
57 8b/copy 1/mod/*+disp8 6/rm32/ESI 0/r32/EAX 8/disp8
58 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX 0/r32/EAX 0xc/disp8
59 50/push-EAX
60
61 8b/copy 0/mod/indirect 6/rm32/ESI 0/r32/EAX
62 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX 0/r32/EAX 0xc/disp8
63 50/push-EAX
64
65 e8/call _append-4/disp32
66
67 81 0/subop/add 3/mod/direct 4/rm32/ESP 0x10/imm32
68
69 01/add 0/mod/indirect 6/rm32/ESI 0/r32/EAX
70
71 01/add 1/mod/*+disp8 7/rm32/EDI 0/r32/EAX 4/disp8
72
73 5f/pop-to-EDI
74 5e/pop-to-ESI
75 58/pop-to-EAX
76 $write-stream:end:
77
78 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
79 5d/pop-to-EBP
80 c3/return
81
82 _write-stream:
83
84 55/push-EBP
85 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
86
87 50/push-EAX
88 51/push-ECX
89 52/push-EDX
90 53/push-EBX
91 56/push-ESI
92 57/push-EDI
93
94 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 0xc/disp8
95
96 8b/copy 1/mod/*+disp8 6/rm32/ESI 7/r32/EDI 4/disp8
97
98 8b/copy 0/mod/indirect 6/rm32/ESI 2/r32/EDX
99
100
101 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 3/r32/EBX 8/disp8
102
103 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 7/index/EDI 1/r32/ECX 0xc/disp8
104
105 29/subtract 3/mod/direct 2/rm32/EDX 7/r32/EDI
106
107 b8/copy-to-EAX 4/imm32/write
108 cd/syscall 0x80/imm8
109
110 5f/pop-to-EDI
111 5e/pop-to-ESI
112 5b/pop-to-EBX
113 5a/pop-to-EDX
114 59/pop-to-ECX
115 58/pop-to-EAX
116
117 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
118 5d/pop-to-EBP
119 c3/return
120
121 test-write-stream-single:
122
123
124
125 68/push _test-stream/imm32
126
127 e8/call clear-stream/disp32
128
129 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
130
131
132 68/push _test-stream2/imm32
133
134 e8/call clear-stream/disp32
135
136 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
137
138
139 68/push "Ab"/imm32
140 68/push _test-stream2/imm32
141
142 e8/call write/disp32
143
144 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
145
146
147 68/push _test-stream2/imm32
148 68/push _test-stream/imm32
149
150 e8/call write-stream/disp32
151
152 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
153
154
155 68/push "F - test-write-stream-single"/imm32
156 68/push 0x006241/imm32/Ab
157
158 b8/copy-to-EAX _test-stream/imm32
159 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
160
161 e8/call check-ints-equal/disp32
162
163 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
164
165 c3/return
166
167 test-write-stream-appends:
168
169
170
171 68/push _test-stream/imm32
172
173 e8/call clear-stream/disp32
174
175 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
176
177
178 68/push _test-stream2/imm32
179
180 e8/call clear-stream/disp32
181
182 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
183
184
185 68/push "C"/imm32
186 68/push _test-stream2/imm32
187
188 e8/call write/disp32
189
190 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
191
192
193
194 68/push _test-stream2/imm32
195 68/push _test-stream/imm32
196
197 e8/call write-stream/disp32
198
199 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
200
201
202
203 68/push "D"/imm32
204 68/push _test-stream2/imm32
205
206 e8/call write/disp32
207
208 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
209
210
211 68/push _test-stream2/imm32
212 68/push _test-stream/imm32
213
214 e8/call write-stream/disp32
215
216 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
217
218
219 68/push "F - test-write-stream-appends"/imm32
220 68/push 0x00004443/imm32/C-D
221
222 b8/copy-to-EAX _test-stream/imm32
223 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
224
225 e8/call check-ints-equal/disp32
226
227 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
228
229 c3/return
230
231 == data
232
233 _test-stream2:
234
235 04 00 00 00
236
237 01 00 00 00
238
239 08 00 00 00
240
241 41 42 43 44 00 00 00 00
242
243