https://github.com/akkartik/mu/blob/main/baremetal/112read-byte.subx
1
2
3
4
5
6 == code
7
8
9
10
11
12
13 read-byte:
14
15 55/push-ebp
16 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
17
18 51/push-ecx
19 56/push-esi
20
21 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
22
23 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
24
25 3b/compare 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
26 0f 8d/jump-if->= $read-byte:abort/disp32
27
28 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
29 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx . 0/r32/AL 0xc/disp8 .
30
31 ff 0/subop/increment 1/mod/*+disp8 6/rm32/esi . . . . 4/disp8 .
32 $read-byte:end:
33
34 5e/pop-to-esi
35 59/pop-to-ecx
36
37 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
38 5d/pop-to-ebp
39 c3/return
40
41 $read-byte:abort:
42 (draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0 "read-byte: empty stream" 3)
43 {
44 eb/jump loop/disp8
45 }
46
47
48