https://github.com/akkartik/mu/blob/master/subx/063print-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
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 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 0xc/disp8
23 c1/shift 5/subop/logic-right 3/mod/direct 0/rm32/EAX 4/imm8
24
25
26 50/push-EAX
27
28 e8/call hex-char/disp32
29
30 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
31
32
33 50/push-EAX
34 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0x8/disp8
35
36 e8/call write-byte/disp32
37
38 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
39
40 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 0xc/disp8
41 25/and-EAX 0xf/imm32
42
43
44 50/push-EAX
45
46 e8/call hex-char/disp32
47
48 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
49
50
51 50/push-EAX
52 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0x8/disp8
53
54 e8/call write-byte/disp32
55
56 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
57
58 59/pop-to-ECX
59 58/pop-to-EAX
60
61 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
62 5d/pop-to-EBP
63 c3/return
64
65
66
67 hex-char:
68
69 55/push-EBP
70 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
71
72 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8
73
74 81 7/subop/compare 3/mod/direct 0/rm32/EAX 0x9/imm32
75 7f/jump-if-greater $hex-char:check2/disp8
76 05/add-to-EAX 0x30/imm32/'0'
77 eb/jump $hex-char:end/disp8
78 $hex-char:check2:
79
80 81 7/subop/compare 3/mod/direct 0/rm32/EAX 0xf/imm32
81 7f/jump-if-greater $hex-char:error/disp8
82 05/add-to-EAX 0x57/imm32
83 eb/jump $hex-char:end/disp8
84 $hex-char:error:
85
86 b8/copy-to-EAX 0xffffffff/imm32
87 $hex-char:end:
88
89 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
90 5d/pop-to-EBP
91 c3/return
92
93 test-print-byte:
94
95
96
97
98 68/push _test-stream/imm32
99
100 e8/call clear-stream/disp32
101
102 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
103
104
105 b8/copy-to-EAX _test-buffered-file/imm32
106 05/add-to-EAX 4/imm32
107 50/push-EAX
108
109 e8/call clear-stream/disp32
110
111 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
112
113
114 68/push 0xa/imm32
115 68/push _test-buffered-file/imm32
116
117 e8/call print-byte/disp32
118
119 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
120
121
122 68/push _test-buffered-file/imm32
123
124 e8/call flush/disp32
125
126 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
127
128
129 68/push "F - test-print-byte"/imm32
130 68/push 0x6130/imm32/0a
131
132 b8/copy-to-EAX _test-stream/imm32
133 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
134
135 e8/call check-ints-equal/disp32
136
137 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
138
139 c3/return
140
141