https://github.com/akkartik/mu/blob/master/subx/062write-byte.subx
1
2
3
4
5
6
7 == data
8
9
10
11 Stdout:
12
13 01 00 00 00
14
15 00 00 00 00
16
17 00 00 00 00
18
19 08 00 00 00
20
21 00 00 00 00 00 00 00 00
22
23
24
25
26 == code
27
28
29
30
31
32 e8/call run-tests/disp32
33
34 8b/copy 0/mod/indirect 5/rm32/.disp32 3/r32/EBX Num-test-failures/disp32
35 b8/copy-to-EAX 1/imm32
36 cd/syscall 0x80/imm8
37
38
39 write-byte:
40
41 55/push-EBP
42 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
43
44 51/push-ECX
45 56/push-ESI
46
47 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 6/r32/ESI 8/disp8
48
49 8b/copy 1/mod/*+disp8 6/rm32/ESI 1/r32/ECX 4/disp8
50
51 3b/compare 1/mod/*+disp8 6/rm32/ESI 1/r32/ECX 0xc/disp8
52 7c/jump-if-lesser $write-byte:to-stream/disp8
53
54
55 56/push-ESI
56
57 e8/call flush/disp32
58
59 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
60
61
62 8d/copy-address 1/mod/*+disp8 6/rm32/ESI 0/r32/EAX 4/disp8
63 50/push-EAX
64
65 e8/call clear-stream/disp32
66
67 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
68 $write-byte:to-stream:
69
70
71 31/xor 3/mod/direct 0/rm32/EAX 0/r32/EAX
72 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/AL 0xc/disp8
73 88/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX 0/r32/AL 0x10/disp8
74
75 ff 0/subop/increment 1/mod/*+disp8 6/rm32/ESI 4/disp8
76
77 5e/pop-to-ESI
78 59/pop-to-ECX
79
80 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
81 5d/pop-to-EBP
82 c3/return
83
84 flush:
85
86 55/push-EBP
87 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
88
89 50/push-EAX
90 51/push-ECX
91
92 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 0/r32/EAX 8/disp8
93
94
95 8d/copy-address 1/mod/*+disp8 0/rm32/EAX 1/r32/ECX 4/disp8
96 51/push-ECX
97 ff 6/subop/push 0/mod/indirect 0/rm32/EAX
98
99 e8/call write-stream/disp32
100
101 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
102
103 59/pop-to-ECX
104 58/pop-to-EAX
105
106 89/copy 3/mod/direct 4/rm32/ESP 5/r32/EBP
107 5d/pop-to-EBP
108 c3/return
109
110
111
112 test-write-byte-single:
113
114
115
116
117 68/push _test-stream/imm32
118
119 e8/call clear-stream/disp32
120
121 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
122
123
124 b8/copy-to-EAX _test-buffered-file/imm32
125 05/add-to-EAX 4/imm32
126 50/push-EAX
127
128 e8/call clear-stream/disp32
129
130 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
131
132
133 68/push 0x41/imm32
134 68/push _test-buffered-file/imm32
135
136 e8/call write-byte/disp32
137
138 81 0/subop/add 3/mod/direct 4/rm32/ESP 8/imm32
139
140
141 68/push _test-buffered-file/imm32
142
143 e8/call flush/disp32
144
145 81 0/subop/add 3/mod/direct 4/rm32/ESP 4/imm32
146
147
148 68/push "F - test-write-byte-single"/imm32
149 68/push 0x41/imm32
150
151 b8/copy-to-EAX _test-stream/imm32
152 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX 0xc/disp8
153
154 e8/call check-ints-equal/disp32
155
156 81 0/subop/add 3/mod/direct 4/rm32/ESP 0xc/imm32
157
158 c3/return
159
160