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 8/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 8/disp8
53
54 e8/call write-byte/disp32
55
56 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
57 $print-byte:end:
58
59 59/pop-to-ECX
60 58/pop-to-EAX
61
62 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
63 5d/pop-to-EBP
64 c3/return
65
66
67
68 hex-char:
69
70 55/push-EBP
71 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
72
73 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8
74
75 81 7/subop/compare 3/mod/direct 0/rm32/EAX 0x9/imm32
76 7f/jump-if-greater $hex-char:check2/disp8
77 05/add-to-EAX 0x30/imm32/'0'
78 eb/jump $hex-char:end/disp8
79 $hex-char:check2:
80
81 81 7/subop/compare 3/mod/direct 0/rm32/EAX 0xf/imm32
82 7f/jump-if-greater $hex-char:error/disp8
83 05/add-to-EAX 0x57/imm32
84 eb/jump $hex-char:end/disp8
85 $hex-char:error:
86
87 b8/copy-to-EAX 0xffffffff/imm32
88 $hex-char:end:
89
90 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
91 5d/pop-to-EBP
92 c3/return
93
94 test-print-byte:
95
96
97
98
99 68/push _test-stream/imm32
100
101 e8/call clear-stream/disp32
102
103 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
104
105
106 b8/copy-to-EAX _test-buffered-file/imm32
107 05/add-to-EAX 4/imm32
108 50/push-EAX
109
110 e8/call clear-stream/disp32
111
112 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
113
114
115 68/push 0xa/imm32
116 68/push _test-buffered-file/imm32
117
118 e8/call print-byte/disp32
119
120 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
121
122
123 68/push _test-buffered-file/imm32
124
125 e8/call flush/disp32
126
127 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
128
129
130 68/push "F - test-print-byte"/imm32
131 68/push 0x6130/imm32/0a
132
133 b8/copy-to-EAX _test-stream/imm32
134 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
135
136 e8/call check-ints-equal/disp32
137
138 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
139
140 c3/return
141
142