https://github.com/akkartik/mu/blob/master/134emit-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-addr>= $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 68/push $_test-output-buffered-file->buffer/imm32
70
71 e8/call clear-stream/disp32
72
73 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
74
75 68/push 0x00030201/imm32
76 68/push 3/imm32/size
77 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
78
79
80 51/push-ecx
81 68/push _test-output-buffered-file/imm32
82
83 e8/call emit-hex-array/disp32
84
85 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
86
87
88 68/push _test-output-buffered-file/imm32
89
90 e8/call flush/disp32
91
92 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
93 +-- 33 lines: #? # dump output ------------------------------------------------------------------------------------------------------------------------------------------------------
126
127
128 68/push "F - test-emit-hex-array"/imm32
129 68/push "01 02 03 "/imm32
130 68/push _test-output-stream/imm32
131
132 e8/call check-next-stream-line-equal/disp32
133
134 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
135
136 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
137 5d/pop-to-ebp
138 c3/return
139
140