https://github.com/akkartik/mu/blob/main/baremetal/108write.subx
1
2
3
4
5
6 == code
7
8
9
10
11 write:
12
13 55/push-ebp
14 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
15
16 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 0/imm32
17 74/jump-if-= $write:end/disp8
18
19 50/push-eax
20 51/push-ecx
21 52/push-edx
22 53/push-ebx
23
24 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 1/r32/ecx 8/disp8 .
25
26 8b/copy 0/mod/indirect 1/rm32/ecx . . . 2/r32/edx . .
27
28 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 3/r32/ebx 8/disp8 .
29
30
31 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
32
33 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 3/index/ebx . 3/r32/ebx 0xc/disp8 .
34 53/push-ebx
35
36 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 2/index/edx . 3/r32/ebx 0xc/disp8 .
37 53/push-ebx
38
39 e8/call _append-3/disp32
40
41 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
42
43 01/add 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
44
45 5b/pop-to-ebx
46 5a/pop-to-edx
47 59/pop-to-ecx
48 58/pop-to-eax
49 $write:end:
50
51 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
52 5d/pop-to-ebp
53 c3/return
54
55 test-write-single:
56
57
58 68/push _test-stream/imm32
59
60 e8/call clear-stream/disp32
61
62 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
63
64
65 68/push "Ab"/imm32
66 68/push _test-stream/imm32
67
68 e8/call write/disp32
69
70 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
71
72
73 68/push "F - test-write-single"/imm32
74 68/push 0x006241/imm32/Ab
75
76 b8/copy-to-eax _test-stream/imm32
77 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 0xc/disp8 .
78
79 e8/call check-ints-equal/disp32
80
81 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
82
83 c3/return
84
85 test-write-appends:
86
87
88 68/push _test-stream/imm32
89
90 e8/call clear-stream/disp32
91
92 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
93
94
95 68/push "C"/imm32
96 68/push _test-stream/imm32
97
98 e8/call write/disp32
99
100 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
101
102
103 68/push "D"/imm32
104 68/push _test-stream/imm32
105
106 e8/call write/disp32
107
108 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
109
110
111 68/push "F - test-write-appends"/imm32
112 68/push 0x00004443/imm32/C-D
113
114 b8/copy-to-eax _test-stream/imm32
115 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . 0xc/disp8 .
116
117 e8/call check-ints-equal/disp32
118
119 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
120
121 c3/return
122
123 == data
124
125 _test-stream:
126
127 0/imm32
128
129 0/imm32
130
131 0x10/imm32
132
133 00 00 00 00 00 00 00 00
134 00 00 00 00 00 00 00 00
135
136 == code
137
138
139 _append-3:
140
141 55/push-ebp
142 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
143
144 51/push-ecx
145
146
147 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 0/r32/eax 0x10/disp8 .
148 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
149 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
150 51/push-ecx
151
152 8d/copy-address 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
153 51/push-ecx
154
155 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
156
157 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
158
159 e8/call _append-4/disp32
160
161 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
162 $_append-3:end:
163
164 59/pop-to-ecx
165
166 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
167 5d/pop-to-ebp
168 c3/return
169
170
171 _append-4:
172
173 55/push-ebp
174 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
175
176 51/push-ecx
177 52/push-edx
178 53/push-ebx
179 56/push-esi
180 57/push-edi
181
182 b8/copy-to-eax 0/imm32
183
184 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
185
186 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
187
188 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0x10/disp8 .
189
190 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0x14/disp8 .
191 $_append-4:loop:
192
193 39/compare 3/mod/direct 6/rm32/esi . . . 1/r32/ecx . .
194 73/jump-if-addr>= $_append-4:end/disp8
195
196 39/compare 3/mod/direct 7/rm32/edi . . . 2/r32/edx . .
197 73/jump-if-addr>= $_append-4:end/disp8
198
199 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 3/r32/BL . .
200 88/copy-byte 0/mod/indirect 7/rm32/edi . . . 3/r32/BL . .
201
202 40/increment-eax
203
204 46/increment-esi
205
206 47/increment-edi
207 eb/jump $_append-4:loop/disp8
208 $_append-4:end:
209
210 5f/pop-to-edi
211 5e/pop-to-esi
212 5b/pop-to-ebx
213 5a/pop-to-edx
214 59/pop-to-ecx
215
216 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
217 5d/pop-to-ebp
218 c3/return
219
220