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