https://github.com/akkartik/mu/blob/master/060read.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 == code
44
45
46
47
48 read:
49
50 55/push-ebp
51 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
52
53 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 0x08000000/imm32
54 73/jump-if-addr>= $read:fake/disp8
55
56 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
57 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
58
59 e8/call _read/disp32
60
61 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
62
63 eb/jump $read:end/disp8
64 $read:fake:
65
66
67 56/push-esi
68 57/push-edi
69
70 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
71
72 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
73
74
75
76 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
77 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
78 50/push-eax
79
80 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
81 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 0/r32/eax 0xc/disp8 .
82 50/push-eax
83
84 8b/copy 1/mod/*+disp8 7/rm32/edi . . . 0/r32/eax 8/disp8 .
85 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/edi 0/index/eax . 0/r32/eax 0xc/disp8 .
86 50/push-eax
87
88 8b/copy 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . .
89 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/edi 0/index/eax . 0/r32/eax 0xc/disp8 .
90 50/push-eax
91
92 e8/call _buffer-4/disp32
93
94 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
95
96 01/add 0/mod/indirect 7/rm32/edi . . . 0/r32/eax . .
97
98 01/add 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
99
100 5f/pop-to-edi
101 5e/pop-to-esi
102 $read:end:
103
104 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
105 5d/pop-to-ebp
106 c3/return
107
108
109
110
111
112
113 _buffer-3:
114
115 55/push-ebp
116 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
117
118 51/push-ecx
119
120
121 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 0/r32/eax 0x10/disp8 .
122 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
123 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
124 51/push-ecx
125
126 8d/copy-address 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
127 51/push-ecx
128
129 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
130
131 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
132
133 e8/call _buffer-4/disp32
134
135 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
136 $_buffer-3:end:
137
138 59/pop-to-ecx
139
140 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
141 5d/pop-to-ebp
142 c3/return
143
144
145 _buffer-4:
146
147 55/push-ebp
148 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
149
150 51/push-ecx
151 52/push-edx
152 53/push-ebx
153 56/push-esi
154 57/push-edi
155
156 b8/copy-to-eax 0/imm32
157
158 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
159
160 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
161
162 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0x10/disp8 .
163
164 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0x14/disp8 .
165 $_buffer-4:loop:
166
167 39/compare 3/mod/direct 6/rm32/esi . . . 1/r32/ecx . .
168 73/jump-if-addr>= $_buffer-4:end/disp8
169
170 39/compare 3/mod/direct 7/rm32/edi . . . 2/r32/edx . .
171 73/jump-if-addr>= $_buffer-4:end/disp8
172
173 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 3/r32/BL . .
174 88/copy-byte 0/mod/indirect 7/rm32/edi . . . 3/r32/BL . .
175
176 40/increment-eax
177
178 46/increment-esi
179
180 47/increment-edi
181 eb/jump $_buffer-4:loop/disp8
182 $_buffer-4:end:
183
184 5f/pop-to-edi
185 5e/pop-to-esi
186 5b/pop-to-ebx
187 5a/pop-to-edx
188 59/pop-to-ecx
189
190 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
191 5d/pop-to-ebp
192 c3/return
193
194
195
196
197
198 _read:
199
200 55/push-ebp
201 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
202
203 51/push-ecx
204 52/push-edx
205 53/push-ebx
206 56/push-esi
207
208 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 .
209
210 8b/copy 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
211
212 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 2/r32/edx 8/disp8 .
213
214
215 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 3/r32/ebx 8/disp8 .
216
217 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax . 1/r32/ecx 0xc/disp8 .
218
219 29/subtract 3/mod/direct 2/rm32/edx . . . 0/r32/eax . .
220
221 e8/call syscall_read/disp32
222
223 01/add 0/mod/indirect 6/rm32/esi . . . 0/r32/eax . .
224 $_read:end:
225
226 5e/pop-to-esi
227 5b/pop-to-ebx
228 5a/pop-to-edx
229 59/pop-to-ecx
230
231 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
232 5d/pop-to-ebp
233 c3/return
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258 test-read-single:
259
260
261
262 68/push _test-stream/imm32
263
264 e8/call clear-stream/disp32
265
266 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
267
268
269 68/push _test-tmp-stream/imm32
270
271 e8/call clear-stream/disp32
272
273 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
274
275
276 68/push "Ab"/imm32
277 68/push _test-stream/imm32
278
279 e8/call write/disp32
280
281 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
282
283
284 68/push _test-tmp-stream/imm32
285 68/push _test-stream/imm32
286
287 e8/call read/disp32
288
289 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
290
291
292 68/push "F - test-read-single: return value"/imm32
293 68/push 2/imm32
294 50/push-eax
295
296 e8/call check-ints-equal/disp32
297
298 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
299
300
301 68/push "F - test-read-single"/imm32
302 68/push "Ab"/imm32
303 68/push _test-tmp-stream/imm32
304
305 e8/call check-stream-equal/disp32
306
307 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
308
309 c3/return
310
311 test-read-is-stateful:
312
313
314
315 68/push _test-stream/imm32
316
317 e8/call clear-stream/disp32
318
319 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
320
321
322 68/push _test-tmp-stream/imm32
323
324 e8/call clear-stream/disp32
325
326 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
327
328
329 68/push "C"/imm32
330 68/push _test-stream/imm32
331
332 e8/call write/disp32
333
334 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
335
336
337 68/push _test-tmp-stream/imm32
338 68/push _test-stream/imm32
339
340 e8/call read/disp32
341
342 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
343
344
345 68/push "D"/imm32
346 68/push _test-stream/imm32
347
348 e8/call write/disp32
349
350 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
351
352
353 68/push _test-tmp-stream/imm32
354 68/push _test-stream/imm32
355
356 e8/call read/disp32
357
358 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
359
360
361 68/push "F - test-read-is-stateful"/imm32
362 68/push "CD"/imm32
363 68/push _test-tmp-stream/imm32
364
365 e8/call check-stream-equal/disp32
366
367 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
368
369 c3/return
370
371 test-read-returns-0-on-end-of-file:
372
373
374
375
376 68/push _test-stream/imm32
377
378 e8/call clear-stream/disp32
379
380 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
381
382
383 68/push _test-tmp-stream/imm32
384
385 e8/call clear-stream/disp32
386
387 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
388
389
390 68/push "Ab"/imm32
391 68/push _test-stream/imm32
392
393 e8/call write/disp32
394
395 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
396
397
398
399 68/push _test-tmp-stream/imm32
400 68/push _test-stream/imm32
401
402 e8/call read/disp32
403
404 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
405
406
407
408 68/push _test-tmp-stream/imm32
409 68/push _test-stream/imm32
410
411 e8/call read/disp32
412
413 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
414
415
416 68/push "F - test-read-returns-0-on-end-of-file"/imm32
417 68/push 0/imm32
418 50/push-eax
419
420 e8/call check-ints-equal/disp32
421
422 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
423
424 c3/return
425
426 == data
427
428 _test-tmp-stream:
429
430 0/imm32
431
432 0/imm32
433
434 8/imm32
435
436 00 00 00 00 00 00 00 00
437
438