https://github.com/akkartik/mu/blob/master/subx/066print-byte.subx
1
2
3 == code
4
5
6
7
8
9 e8/call run-tests/disp32
10
11 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
12 b8/copy-to-EAX 1/imm32/exit
13 cd/syscall 0x80/imm8
14
15 print-byte:
16
17 55/push-EBP
18 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
19
20 50/push-EAX
21
22 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
23 c1/shift 5/subop/logic-right 3/mod/direct 0/rm32/EAX . . . . . 4/imm8
24 25/and-EAX 0xf/imm32
25
26 e8/call to-hex-char/disp32
27
28
29 50/push-EAX
30 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
31
32 e8/call write-byte/disp32
33
34 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
35
36 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
37 25/and-EAX 0xf/imm32
38
39 e8/call to-hex-char/disp32
40
41
42 50/push-EAX
43 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
44
45 e8/call write-byte/disp32
46
47 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
48 $print-byte:end:
49
50 58/pop-to-EAX
51
52 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
53 5d/pop-to-EBP
54 c3/return
55
56 test-print-byte:
57
58
59
60
61 68/push _test-stream/imm32
62
63 e8/call clear-stream/disp32
64
65 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
66
67
68 b8/copy-to-EAX _test-buffered-file/imm32
69 05/add-to-EAX 4/imm32
70 50/push-EAX
71
72 e8/call clear-stream/disp32
73
74 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
75
76
77 68/push 0xa/imm32
78 68/push _test-buffered-file/imm32
79
80 e8/call print-byte/disp32
81
82 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
83
84
85 68/push _test-buffered-file/imm32
86
87 e8/call flush/disp32
88
89 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
90
91
92 68/push "F - test-print-byte"/imm32
93 68/push "0a"/imm32
94 68/push _test-stream/imm32
95
96 e8/call check-stream-equal/disp32
97
98 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
99
100 c3/return
101
102