https://github.com/akkartik/mu/blob/master/133subx-widths.subx
1
2
3
4
5
6 == code
7
8
9
10
11 compute-width:
12
13 55/push-ebp
14 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
15
16 51/push-ecx
17
18 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 8/disp8 .
19
20 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
21 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
22
23 05/add-to-eax 4/imm32
24
25 51/push-ecx
26 50/push-eax
27 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
28
29
30 51/push-ecx
31
32 e8/call compute-width-of-slice/disp32
33
34 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
35 $compute-width:end:
36
37 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
38
39 59/pop-to-ecx
40
41 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
42 5d/pop-to-ebp
43 c3/return
44
45 compute-width-of-slice:
46
47 55/push-ebp
48 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
49
50 51/push-ecx
51
52 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
53
54
55
56 68/push "imm32"/imm32
57 51/push-ecx
58
59 e8/call has-metadata?/disp32
60
61 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
62
63 3d/compare-eax-and 0/imm32/false
64 b8/copy-to-eax 4/imm32
65 75/jump-if-!= $compute-width-of-slice:end/disp8
66
67
68
69 68/push "disp32"/imm32
70 51/push-ecx
71
72 e8/call has-metadata?/disp32
73
74 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
75
76 3d/compare-eax-and 0/imm32/false
77 b8/copy-to-eax 4/imm32
78 75/jump-if-!= $compute-width-of-slice:end/disp8
79
80
81
82 68/push "imm16"/imm32
83 51/push-ecx
84
85 e8/call has-metadata?/disp32
86
87 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
88
89 3d/compare-eax-and 0/imm32/false
90 b8/copy-to-eax 2/imm32
91 75/jump-if-!= $compute-width-of-slice:end/disp8
92
93
94
95 68/push "disp16"/imm32
96 51/push-ecx
97
98 e8/call has-metadata?/disp32
99
100 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
101
102 3d/compare-eax-and 0/imm32/false
103 b8/copy-to-eax 2/imm32
104 75/jump-if-!= $compute-width-of-slice:end/disp8
105
106 b8/copy-to-eax 1/imm32
107 $compute-width-of-slice:end:
108
109 59/pop-to-ecx
110
111 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
112 5d/pop-to-ebp
113 c3/return
114
115 test-compute-width:
116
117 55/push-ebp
118 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
119 $test-compute-width:imm8:
120
121
122 68/push "0x2/imm8"/imm32
123
124 e8/call compute-width/disp32
125
126 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
127
128
129 68/push "F - test-compute-width: 0x2/imm8"/imm32
130 50/push-eax
131 68/push 1/imm32
132
133 e8/call check-ints-equal/disp32
134
135 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
136 $test-compute-width:imm16:
137
138
139 68/push "4/imm16"/imm32
140
141 e8/call compute-width/disp32
142
143 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
144
145
146 68/push "F - test-compute-width: 4/imm16"/imm32
147 50/push-eax
148 68/push 2/imm32
149
150 e8/call check-ints-equal/disp32
151
152 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
153 $test-compute-width:imm32:
154
155
156 68/push "4/imm32"/imm32
157
158 e8/call compute-width/disp32
159
160 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
161
162
163 68/push "F - test-compute-width: 4/imm32"/imm32
164 50/push-eax
165 68/push 4/imm32
166
167 e8/call check-ints-equal/disp32
168
169 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
170 $test-compute-width:disp8:
171
172
173 68/push "foo/disp8"/imm32
174
175 e8/call compute-width/disp32
176
177 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
178
179
180 68/push "F - test-compute-width: foo/disp8"/imm32
181 50/push-eax
182 68/push 1/imm32
183
184 e8/call check-ints-equal/disp32
185
186 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
187 $test-compute-width:disp16:
188
189
190 68/push "foo/disp16"/imm32
191
192 e8/call compute-width/disp32
193
194 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
195
196
197 68/push "F - test-compute-width: foo/disp16"/imm32
198 50/push-eax
199 68/push 2/imm32
200
201 e8/call check-ints-equal/disp32
202
203 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
204 $test-compute-width:disp32:
205
206
207 68/push "foo/disp32"/imm32
208
209 e8/call compute-width/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
212
213
214 68/push "F - test-compute-width: foo/disp32"/imm32
215 50/push-eax
216 68/push 4/imm32
217
218 e8/call check-ints-equal/disp32
219
220 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
221 $test-compute-width:no-metadata:
222
223
224 68/push "45"/imm32
225
226 e8/call compute-width/disp32
227
228 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
229
230
231 68/push "F - test-compute-width: 45 (no metadata)"/imm32
232 50/push-eax
233 68/push 1/imm32
234
235 e8/call check-ints-equal/disp32
236
237 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
238
239 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
240 5d/pop-to-ebp
241 c3/return
242
243