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