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