https://github.com/akkartik/mu/blob/master/subx/062write-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/exit
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 5/rm32/EBP . . . . 8/disp8 0x08000000/imm32
28 7d/jump-if-greater-or-equal $write-stream:fake/disp8
29
30 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
31 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 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 5/rm32/EBP . . 7/r32/EDI 8/disp8 .
45
46 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 6/r32/ESI 0xc/disp8 .
47
48
49 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
50 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
51 50/push-EAX
52
53 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
54 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
55 50/push-EAX
56
57 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 8/disp8 .
58 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
59 50/push-EAX
60
61 8b/copy 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
62 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 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 7/rm32/EDI . . . 0/r32/EAX . .
70
71 01/add 1/mod/*+disp8 6/rm32/ESI . . . 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 5/rm32/EBP . . . 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 5/rm32/EBP . . . 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 "Ab"/imm32
157 68/push _test-stream/imm32
158
159 e8/call check-stream-equal/disp32
160
161 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
162
163 c3/return
164
165 test-write-stream-appends:
166
167
168
169 68/push _test-stream/imm32
170
171 e8/call clear-stream/disp32
172
173 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
174
175
176 68/push _test-stream2/imm32
177
178 e8/call clear-stream/disp32
179
180 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
181
182
183 68/push "C"/imm32
184 68/push _test-stream2/imm32
185
186 e8/call write/disp32
187
188 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
189
190
191
192 68/push _test-stream2/imm32
193 68/push _test-stream/imm32
194
195 e8/call write-stream/disp32
196
197 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
198
199
200
201 68/push "D"/imm32
202 68/push _test-stream2/imm32
203
204 e8/call write/disp32
205
206 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
207
208
209 68/push _test-stream2/imm32
210 68/push _test-stream/imm32
211
212 e8/call write-stream/disp32
213
214 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
215
216
217 68/push "F - test-write-stream-appends"/imm32
218 68/push "CD"/imm32
219 68/push _test-stream/imm32
220
221 e8/call check-stream-equal/disp32
222
223 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
224
225 c3/return
226
227 == data
228
229 _test-stream2:
230
231 04 00 00 00
232
233 01 00 00 00
234
235 08 00 00 00
236
237 41 42 43 44 00 00 00 00
238
239