https://github.com/akkartik/mu/blob/master/084emit-hex-array.subx
1 == code
2
3
4
5
6
7 emit-hex-array:
8
9 55/push-ebp
10 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
11
12 50/push-eax
13 51/push-ecx
14 52/push-edx
15 57/push-edi
16
17 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
18
19 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
20
21 8d/copy-address 1/mod/*+disp8 2/rm32/edx . . . 1/r32/ecx 4/disp8 .
22
23 8b/copy 0/mod/indirect 2/rm32/edx . . . 2/r32/edx . .
24 01/add 3/mod/direct 2/rm32/edx . . . 1/r32/ecx . .
25
26 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
27 $emit-hex-array:loop:
28
29 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
30 73/jump-if-greater-or-equal-unsigned $emit-hex-array:end/disp8
31
32
33 68/push 1/imm32/width
34 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
35 50/push-eax
36 57/push-edi
37
38 e8/call emit-hex/disp32
39
40 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
41
42 41/increment-ecx
43 eb/jump $emit-hex-array:loop/disp8
44 $emit-hex-array:end:
45
46 5f/pop-to-edi
47 5a/pop-to-edx
48 59/pop-to-ecx
49 58/pop-to-eax
50
51 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
52 5d/pop-to-ebp
53 c3/return
54
55 test-emit-hex-array:
56
57 55/push-ebp
58 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
59
60
61
62 68/push _test-output-stream/imm32
63
64 e8/call clear-stream/disp32
65
66 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
67
68
69 b8/copy-to-eax _test-output-buffered-file/imm32
70 05/add-to-eax 4/imm32
71 50/push-eax
72
73 e8/call clear-stream/disp32
74
75 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
76
77 68/push 0x00030201/imm32
78 68/push 3/imm32/length
79 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
80
81
82 51/push-ecx
83 68/push _test-output-buffered-file/imm32
84
85 e8/call emit-hex-array/disp32
86
87 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
88
89
90 68/push _test-output-buffered-file/imm32
91
92 e8/call flush/disp32
93
94 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
95 +-- 33 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
128
129
130 68/push "F - test-emit-hex-array"/imm32
131 68/push "01 02 03 "/imm32
132 68/push _test-output-stream/imm32
133
134 e8/call check-next-stream-line-equal/disp32
135
136 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
137
138 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
139 5d/pop-to-ebp
140 c3/return
141
142