https://github.com/akkartik/mu/blob/main/309stream.subx
1
2
3
4 == code
5
6 stream-empty?:
7
8 55/push-ebp
9 89/<- %ebp 4/r32/esp
10
11 51/push-ecx
12 56/push-esi
13
14 b8/copy-to-eax 0/imm32/false
15
16 8b/-> *(ebp+8) 6/r32/esi
17
18 8b/-> *esi 1/r32/ecx
19 39/compare-with *(esi+4) 1/r32/ecx
20 0f 9d/set-if->= %al
21 $stream-empty?:end:
22
23 5e/pop-to-esi
24 59/pop-to-ecx
25
26 89/<- %esp 5/r32/ebp
27 5d/pop-to-ebp
28 c3/return
29
30 stream-full?:
31
32 55/push-ebp
33 89/<- %ebp 4/r32/esp
34
35 51/push-ecx
36 56/push-esi
37
38 b8/copy-to-eax 0/imm32/false
39
40 8b/-> *(ebp+8) 6/r32/esi
41
42 8b/-> *(esi+8) 1/r32/ecx
43 39/compare-with *esi 1/r32/ecx
44 0f 9d/set-if->= %al
45 $stream-full?:end:
46
47 5e/pop-to-esi
48 59/pop-to-ecx
49
50 89/<- %esp 5/r32/ebp
51 5d/pop-to-ebp
52 c3/return
53
54 write-to-stream:
55
56 55/push-ebp
57 89/<- %ebp 4/r32/esp
58
59 50/push-eax
60 51/push-ecx
61 52/push-edx
62 53/push-ebx
63 57/push-edi
64
65 8b/-> *(ebp+8) 7/r32/edi
66
67 8b/-> *edi 2/r32/edx
68
69 8b/-> *(ebp+0x10) 1/r32/ecx
70 01/add-to %ecx 2/r32/edx
71 3b/compare 1/r32/ecx *(edi+8)
72 0f 8f/jump-if-> $write-to-stream:abort/disp32
73
74 8d/copy-address *(edi+edx+0xc) 2/r32/edx
75
76 8b/-> *(ebp+0x10) 3/r32/ebx
77 8d/copy-address *(edx+ebx) 3/r32/ebx
78
79 8b/-> *(ebp+0xc) 0/r32/eax
80
81 8b/-> *(ebp+0x10) 1/r32/ecx
82 8d/copy-address *(eax+ecx) 1/r32/ecx
83
84 (_append-4 %edx %ebx %eax %ecx)
85
86 8b/-> *(ebp+0x10) 1/r32/ecx
87 01/add-to *edi 1/r32/ecx
88 $write-to-stream:end:
89
90 5f/pop-to-edi
91 5b/pop-to-ebx
92 5a/pop-to-edx
93 59/pop-to-ecx
94 58/pop-to-eax
95
96 89/<- %esp 5/r32/ebp
97 5d/pop-to-ebp
98 c3/return
99
100 $write-to-stream:abort:
101 (abort "write-to-stream: stream full")
102
103
104 read-from-stream:
105
106 55/push-ebp
107 89/<- %ebp 4/r32/esp
108
109 50/push-eax
110 51/push-ecx
111 52/push-edx
112 53/push-ebx
113 56/push-esi
114
115 8b/-> *(ebp+8) 6/r32/esi
116
117 8b/-> *(esi+4) 2/r32/edx
118
119 8b/-> *(ebp+0x10) 1/r32/ecx
120 01/add-to %ecx 2/r32/edx
121 3b/compare 1/r32/ecx *esi
122 0f 8f/jump-if-> $read-from-stream:abort/disp32
123
124 8d/copy-address *(esi+edx+0xc) 2/r32/edx
125
126 8b/-> *(ebp+0x10) 3/r32/ebx
127 8d/copy-address *(edx+ebx) 3/r32/ebx
128
129 8b/-> *(ebp+0xc) 0/r32/eax
130
131 8b/-> *(ebp+0x10) 1/r32/ecx
132 8d/copy-address *(eax+ecx) 1/r32/ecx
133
134 (_append-4 %eax %ecx %edx %ebx)
135
136 8b/-> *(ebp+0x10) 1/r32/ecx
137 01/add-to *(esi+4) 1/r32/ecx
138 $read-from-stream:end:
139
140 5e/pop-to-esi
141 5b/pop-to-ebx
142 5a/pop-to-edx
143 59/pop-to-ecx
144 58/pop-to-eax
145
146 89/<- %esp 5/r32/ebp
147 5d/pop-to-ebp
148 c3/return
149
150 $read-from-stream:abort:
151 (abort "read-from-stream: stream empty")
152
153
154 stream-first:
155
156 55/push-ebp
157 89/<- %ebp 4/r32/esp
158
159 51/push-ecx
160 56/push-esi
161
162 b8/copy-to-eax 0/imm32
163
164 8b/-> *(ebp+8) 6/r32/esi
165
166 8b/-> *(esi+4) 1/r32/ecx
167
168 3b/compare-with 1/r32/ecx *esi
169 7d/jump-if->= $stream-first:end/disp8
170
171 8a/byte-> *(esi+ecx+0xc) 0/r32/AL
172 $stream-first:end:
173
174 5e/pop-to-esi
175 59/pop-to-ecx
176
177 89/<- %esp 5/r32/ebp
178 5d/pop-to-ebp
179 c3/return
180
181 stream-final:
182
183 55/push-ebp
184 89/<- %ebp 4/r32/esp
185
186 51/push-ecx
187 56/push-esi
188
189 b8/copy-to-eax 0/imm32
190
191 8b/-> *(ebp+8) 6/r32/esi
192
193 8b/-> *esi 1/r32/ecx
194
195 39/compare-with *(esi+4) 1/r32/ecx
196 7d/jump-if->= $stream-final:end/disp8
197
198 49/decrement-ecx
199
200 8a/byte-> *(esi+ecx+0xc) 0/r32/AL
201 $stream-final:end:
202
203 5e/pop-to-esi
204 59/pop-to-ecx
205
206 89/<- %esp 5/r32/ebp
207 5d/pop-to-ebp
208 c3/return
209
210
211 streams-data-equal?:
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 55/push-ebp
235 89/<- %ebp 4/r32/esp
236
237 51/push-ecx
238 52/push-edx
239 53/push-ebx
240 56/push-esi
241 57/push-edi
242
243 8b/-> *(ebp+8) 6/r32/esi
244
245 8b/-> *(ebp+0xc) 7/r32/edi
246
247 8b/-> *esi 2/r32/edx
248 $streams-data-equal?:sizes:
249
250 39/compare *edi 2/r32/edx
251 75/jump-if-!= $streams-data-equal?:false/disp8
252
253 81 0/subop/add %esi 0xc/imm32
254
255 81 0/subop/add %edi 0xc/imm32
256
257 31/xor-with %ecx 1/r32/ecx
258
259 31/xor-with %eax 0/r32/eax
260
261 31/xor-with %ebx 3/r32/ebx
262 $streams-data-equal?:loop:
263 {
264
265 39/compare %ecx 2/r32/edx
266 7d/jump-if->= $streams-data-equal?:true/disp8
267
268 8a/byte-> *esi 0/r32/eax
269
270 8a/byte-> *edi 3/r32/ebx
271
272 39/compare %eax 3/r32/ebx
273 75/jump-if-!= $streams-data-equal?:false/disp8
274
275 41/increment-ecx
276
277 46/increment-esi
278
279 47/increment-edi
280 eb/jump loop/disp8
281 }
282 $streams-data-equal?:true:
283 b8/copy-to-eax 1/imm32
284 eb/jump $streams-data-equal?:end/disp8
285 $streams-data-equal?:false:
286 b8/copy-to-eax 0/imm32
287 $streams-data-equal?:end:
288
289 5f/pop-to-edi
290 5e/pop-to-esi
291 5b/pop-to-ebx
292 5a/pop-to-edx
293 59/pop-to-ecx
294
295 89/<- %esp 5/r32/ebp
296 5d/pop-to-ebp
297 c3/return
298
299
300 check-streams-data-equal:
301
302 55/push-ebp
303 89/<- %ebp 4/r32/esp
304
305 50/push-eax
306
307 (streams-data-equal? *(ebp+8) *(ebp+0xc))
308 (check-ints-equal %eax 1 *(ebp+0x10))
309 $check-streams-equal:end:
310
311 58/pop-to-eax
312
313 89/<- %esp 5/r32/ebp
314 5d/pop-to-ebp
315 c3/return