https://github.com/akkartik/mu/blob/master/subx/067print-int.subx
1
2
3 == code
4
5
6
7
8 append-byte-hex:
9
10 55/push-EBP
11 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
12
13 50/push-EAX
14
15 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
16 c1/shift 5/subop/logic-right 3/mod/direct 0/rm32/EAX . . . . . 4/imm8
17 25/and-EAX 0xf/imm32
18
19 e8/call to-hex-char/disp32
20
21
22 50/push-EAX
23 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
24
25 e8/call append-byte/disp32
26
27 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
28
29 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
30 25/and-EAX 0xf/imm32
31
32 e8/call to-hex-char/disp32
33
34
35 50/push-EAX
36 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
37
38 e8/call append-byte/disp32
39
40 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
41 $append-byte-hex:end:
42
43 58/pop-to-EAX
44
45 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
46 5d/pop-to-EBP
47 c3/return
48
49 test-append-byte-hex:
50
51
52
53
54 68/push _test-stream/imm32
55
56 e8/call clear-stream/disp32
57
58 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
59
60
61 68/push 0xa/imm32
62 68/push _test-stream/imm32
63
64 e8/call append-byte-hex/disp32
65
66 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
67
68
69 68/push "F - test-append-byte-hex"/imm32
70 68/push "0a"/imm32
71 68/push _test-stream/imm32
72
73 e8/call check-stream-equal/disp32
74
75 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
76
77 c3/return
78
79
80 print-byte-buffered:
81
82 55/push-EBP
83 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
84
85 50/push-EAX
86
87 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
88 c1/shift 5/subop/logic-right 3/mod/direct 0/rm32/EAX . . . . . 4/imm8
89 25/and-EAX 0xf/imm32
90
91 e8/call to-hex-char/disp32
92
93
94 50/push-EAX
95 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
96
97 e8/call write-byte-buffered/disp32
98
99 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
100
101 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
102 25/and-EAX 0xf/imm32
103
104 e8/call to-hex-char/disp32
105
106
107 50/push-EAX
108 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
109
110 e8/call write-byte-buffered/disp32
111
112 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
113 $print-byte-buffered:end:
114
115 58/pop-to-EAX
116
117 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
118 5d/pop-to-EBP
119 c3/return
120
121 test-print-byte-buffered:
122
123
124
125
126 68/push _test-stream/imm32
127
128 e8/call clear-stream/disp32
129
130 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
131
132
133 b8/copy-to-EAX _test-buffered-file/imm32
134 05/add-to-EAX 4/imm32
135 50/push-EAX
136
137 e8/call clear-stream/disp32
138
139 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
140
141
142 68/push 0xa/imm32
143 68/push _test-buffered-file/imm32
144
145 e8/call print-byte-buffered/disp32
146
147 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
148
149
150 68/push _test-buffered-file/imm32
151
152 e8/call flush/disp32
153
154 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
155
156
157 68/push "F - test-print-byte-buffered"/imm32
158 68/push "0a"/imm32
159 68/push _test-stream/imm32
160
161 e8/call check-stream-equal/disp32
162
163 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
164
165 c3/return
166
167 print-int32:
168
169
170
171
172
173
174
175
176
177
178
179 55/push-EBP
180 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
181
182 50/push-EAX
183 51/push-ECX
184
185 b9/copy-to-ECX 0x1c/imm32
186 $print-int32:print-hex-prefix:
187
188
189 68/push "0x"/imm32
190 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
191
192 e8/call write/disp32
193
194 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
195 $print-int32:loop:
196
197 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0/imm32
198 7c/jump-if-lesser $print-int32:end/disp8
199
200 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
201 d3/>>ECX 5/subop/pad-zeroes 3/mod/direct 0/rm32/EAX . . . . . .
202
203 25/and-EAX 0xf/imm32
204 e8/call to-hex-char/disp32
205
206
207 50/push-EAX
208 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
209
210 e8/call append-byte/disp32
211
212 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
213
214 81 5/subop/subtract 3/mod/direct 1/rm32/ECX . . . . . 4/imm32
215 eb/jump $print-int32:loop/disp8
216 $print-int32:end:
217
218 59/pop-to-ECX
219 58/pop-to-EAX
220
221 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
222 5d/pop-to-EBP
223 c3/return
224
225 test-print-int32:
226
227
228
229
230 68/push _test-stream/imm32
231
232 e8/call clear-stream/disp32
233
234 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
235
236
237 68/push 0x8899aa/imm32
238 68/push _test-stream/imm32
239
240 e8/call print-int32/disp32
241
242 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
243
244
245 68/push "F - test-print-int32"/imm32
246 68/push "0x008899aa"/imm32
247 68/push _test-stream/imm32
248
249 e8/call check-stream-equal/disp32
250
251 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
252
253 c3/return
254
255
256 check-ints-equal2:
257
258 55/push-EBP
259 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
260 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
261 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
262 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
263 e8/call check-ints-equal/disp32
264
265 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
266 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
267
268 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
269 5d/pop-to-EBP
270 c3/return
271
272 print-int32-buffered:
273
274
275
276
277
278
279
280
281
282
283
284 55/push-EBP
285 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
286
287 50/push-EAX
288 51/push-ECX
289
290 b9/copy-to-ECX 0x1c/imm32
291 $print-int32-buffered:print-hex-prefix:
292
293
294 68/push "0x"/imm32
295 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
296
297 e8/call write-buffered/disp32
298
299 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
300 $print-int32-buffered:loop:
301
302 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0/imm32
303 7c/jump-if-lesser $print-int32-buffered:end/disp8
304
305 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
306 d3/>>ECX 5/subop/pad-zeroes 3/mod/direct 0/rm32/EAX . . . . . .
307
308 25/and-EAX 0xf/imm32
309 e8/call to-hex-char/disp32
310
311
312 50/push-EAX
313 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
314
315 e8/call write-byte-buffered/disp32
316
317 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
318
319 81 5/subop/subtract 3/mod/direct 1/rm32/ECX . . . . . 4/imm32
320 eb/jump $print-int32-buffered:loop/disp8
321 $print-int32-buffered:end:
322
323 59/pop-to-ECX
324 58/pop-to-EAX
325
326 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
327 5d/pop-to-EBP
328 c3/return
329
330 test-print-int32-buffered:
331
332
333
334
335 68/push _test-stream/imm32
336
337 e8/call clear-stream/disp32
338
339 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
340
341
342 b8/copy-to-EAX _test-buffered-file/imm32
343 05/add-to-EAX 4/imm32
344 50/push-EAX
345
346 e8/call clear-stream/disp32
347
348 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
349
350
351 68/push 0x8899aa/imm32
352 68/push _test-buffered-file/imm32
353
354 e8/call print-int32-buffered/disp32
355
356 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
357
358
359 68/push _test-buffered-file/imm32
360
361 e8/call flush/disp32
362
363 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
364 +-- 18 lines: #? # dump line -----------------------------------------------------------------------------------------------------------------------------
382
383
384 68/push "F - test-print-int32-buffered"/imm32
385 68/push "0x008899aa"/imm32
386 68/push _test-stream/imm32
387
388 e8/call check-stream-equal/disp32
389
390 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
391
392 c3/return
393
394