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