https://github.com/akkartik/mu/blob/master/100array-equal.subx
1
2
3 == code
4
5 array-equal?:
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 55/push-ebp
29 89/<- %ebp 4/r32/esp
30
31 51/push-ecx
32 52/push-edx
33 53/push-ebx
34 56/push-esi
35 57/push-edi
36
37 8b/-> *(ebp+8) 6/r32/esi
38
39 8b/-> *(ebp+0xc) 7/r32/edi
40
41 8b/-> *esi 2/r32/edx
42 $array-equal?:lengths:
43
44 39/compare *edi 2/r32/edx
45 75/jump-if-!= $array-equal?:false/disp8
46
47 81 0/subop/add %esi 4/imm32
48
49 81 0/subop/add %edi 4/imm32
50
51 31/xor %ecx 1/r32/ecx
52
53
54 $array-equal?:loop:
55
56 39/compare %ecx 2/r32/edx
57 7d/jump-if->= $array-equal?:true/disp8
58
59 8b/-> *esi 0/r32/eax
60
61 8b/-> *edi 3/r32/ebx
62
63 39/compare %eax 3/r32/ebx
64 75/jump-if-!= $array-equal?:false/disp8
65
66 81 0/subop/add %ecx 4/imm32
67
68 81 0/subop/add %esi 4/imm32
69
70 81 0/subop/add %edi 4/imm32
71 eb/jump $array-equal?:loop/disp8
72 $array-equal?:true:
73 b8/copy-to-eax 1/imm32
74 eb/jump $array-equal?:end/disp8
75 $array-equal?:false:
76 b8/copy-to-eax 0/imm32
77 $array-equal?:end:
78
79 5f/pop-to-edi
80 5e/pop-to-esi
81 5b/pop-to-ebx
82 5a/pop-to-edx
83 59/pop-to-ecx
84
85 89/<- %esp 5/r32/ebp
86 5d/pop-to-ebp
87 c3/return
88
89 test-compare-empty-with-empty-array:
90
91 55/push-ebp
92 89/<- %ebp 4/r32/esp
93
94 68/push 0/imm32/size
95 89/<- %ecx 4/r32/esp
96
97 68/push 0/imm32/size
98 89/<- %edx 4/r32/esp
99
100
101 52/push-edx
102 51/push-ecx
103
104 e8/call array-equal?/disp32
105
106 81 0/subop/add %esp 8/imm32
107
108
109 68/push "F - test-compare-empty-with-empty-array"/imm32
110 68/push 1/imm32/true
111 50/push-eax
112
113 e8/call check-ints-equal/disp32
114
115 81 0/subop/add %esp 0xc/imm32
116
117 89/<- %esp 5/r32/ebp
118 5d/pop-to-ebp
119 c3/return
120
121 test-compare-empty-with-non-empty-array:
122
123 55/push-ebp
124 89/<- %ebp 4/r32/esp
125
126 68/push 1/imm32
127 68/push 4/imm32/size
128 89/<- %ecx 4/r32/esp
129
130 68/push 0/imm32/size
131 89/<- %edx 4/r32/esp
132
133
134 52/push-edx
135 51/push-ecx
136
137 e8/call array-equal?/disp32
138
139 81 0/subop/add %esp 8/imm32
140
141
142 68/push "F - test-compare-empty-with-non-empty-array"/imm32
143 68/push 0/imm32/false
144 50/push-eax
145
146 e8/call check-ints-equal/disp32
147
148 81 0/subop/add %esp 0xc/imm32
149
150 89/<- %esp 5/r32/ebp
151 5d/pop-to-ebp
152 c3/return
153
154 test-compare-equal-arrays:
155
156 55/push-ebp
157 89/<- %ebp 4/r32/esp
158
159 68/push 3/imm32
160 68/push 2/imm32
161 68/push 1/imm32
162 68/push 0xc/imm32/size
163 89/<- %ecx 4/r32/esp
164
165 68/push 3/imm32
166 68/push 2/imm32
167 68/push 1/imm32
168 68/push 0xc/imm32/size
169 89/<- %edx 4/r32/esp
170
171
172 52/push-edx
173 51/push-ecx
174
175 e8/call array-equal?/disp32
176
177 81 0/subop/add %esp 8/imm32
178
179
180 68/push "F - test-compare-equal-arrays"/imm32
181 68/push 1/imm32/true
182 50/push-eax
183
184 e8/call check-ints-equal/disp32
185
186 81 0/subop/add %esp 0xc/imm32
187
188 89/<- %esp 5/r32/ebp
189 5d/pop-to-ebp
190 c3/return
191
192 test-compare-inequal-arrays-equal-lengths:
193
194 55/push-ebp
195 89/<- %ebp 4/r32/esp
196
197 68/push 3/imm32
198 68/push 4/imm32
199 68/push 1/imm32
200 68/push 0xc/imm32/size
201 89/<- %ecx 4/r32/esp
202
203 68/push 3/imm32
204 68/push 2/imm32
205 68/push 1/imm32
206 68/push 0xc/imm32/size
207 89/<- %edx 4/r32/esp
208
209
210 52/push-edx
211 51/push-ecx
212
213 e8/call array-equal?/disp32
214
215 81 0/subop/add %esp 8/imm32
216
217
218 68/push "F - test-compare-inequal-arrays-equal-lengths"/imm32
219 68/push 0/imm32/false
220 50/push-eax
221
222 e8/call check-ints-equal/disp32
223
224 81 0/subop/add %esp 0xc/imm32
225
226 89/<- %esp 5/r32/ebp
227 5d/pop-to-ebp
228 c3/return
229
230 parse-array-of-ints:
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256 55/push-ebp
257 89/<- %ebp 4/r32/esp
258
259 51/push-ecx
260 52/push-edx
261 53/push-ebx
262 56/push-esi
263 57/push-edi
264
265 8b/-> *(ebp+0xc) 6/r32/esi
266
267 8d/copy-address *(esi+4) 1/r32/ecx
268
269
270 8b/-> *esi 2/r32/edx
271
272 01/add %edx 1/r32/ecx
273
274 31/xor %ebx 3/r32/ebx
275 $parse-array-of-ints:loop1:
276
277 39/compare %ecx 2/r32/edx
278 73/jump-if-addr>= $parse-array-of-ints:break1/disp8
279
280
281
282 68/push 0x20/imm32/space
283 52/push-edx
284 51/push-ecx
285
286 e8/call skip-chars-matching-in-slice/disp32
287
288 81 0/subop/add %esp 0xc/imm32
289
290 89/<- %ecx 0/r32/eax
291
292 39/compare %ecx 2/r32/edx
293 73/jump-if-addr>= $parse-array-of-ints:break1/disp8
294
295
296
297 68/push 0x20/imm32/space
298 52/push-edx
299 51/push-ecx
300
301 e8/call skip-chars-not-matching-in-slice/disp32
302
303 81 0/subop/add %esp 0xc/imm32
304
305 89/<- %ecx 0/r32/eax
306
307 81 0/subop/add %ebx 4/imm32
308 eb/jump $parse-array-of-ints:loop1/disp8
309 $parse-array-of-ints:break1:
310
311
312
313 89/<- %eax 3/r32/ebx
314 05/add-to-eax 4/imm32
315 50/push-eax
316 ff 6/subop/push *(ebp+8)
317
318 e8/call allocate/disp32
319
320 81 0/subop/add %esp 8/imm32
321
322 89/<- %edi 0/r32/eax
323
324 89/<- *eax 3/r32/ebx
325 $parse-array-of-ints:pass2:
326
327 68/push 0/imm32/end
328 8d/copy-address *(esi+4) 1/r32/ecx
329 51/push-ecx
330 89/<- %ecx 4/r32/esp
331
332 8d/copy-address *(eax+4) 3/r32/ebx
333 $parse-array-of-ints:loop2:
334
335 39/compare *ecx 2/r32/edx
336 73/jump-if-addr>= $parse-array-of-ints:end/disp8
337
338
339
340 68/push 0x20/imm32/space
341 52/push-edx
342 ff 6/subop/push *ecx
343
344 e8/call skip-chars-matching-in-slice/disp32
345
346 81 0/subop/add %esp 0xc/imm32
347
348 89/<- *ecx 0/r32/eax
349
350 39/compare *ecx 2/r32/edx
351 73/jump-if-addr>= $parse-array-of-ints:end/disp8
352
353
354
355 68/push 0x20/imm32/space
356 52/push-edx
357 50/push-eax
358
359 e8/call skip-chars-not-matching-in-slice/disp32
360
361 81 0/subop/add %esp 0xc/imm32
362
363 89/<- *(ecx+4) 0/r32/eax
364
365
366
367 51/push-ecx
368
369 e8/call parse-hex-int-from-slice/disp32
370
371 81 0/subop/add %esp 4/imm32
372
373 89/<- *ebx 0/r32/eax
374
375 81 0/subop/add %ebx 4/imm32
376
377 8b/-> *(ecx+4) 0/r32/eax
378 89/<- *ecx 0/r32/eax
379 81 0/subop/add %ecx 4/imm32
380 eb/jump $parse-array-of-ints:loop2/disp8
381 $parse-array-of-ints:end:
382
383 89/<- %eax 7/r32/edi
384
385 81 0/subop/add %esp 8/imm32
386
387 5f/pop-to-edi
388 5e/pop-to-esi
389 5b/pop-to-ebx
390 5a/pop-to-edx
391 59/pop-to-ecx
392
393 89/<- %esp 5/r32/ebp
394 5d/pop-to-ebp
395 c3/return
396
397 test-parse-array-of-ints:
398
399 55/push-ebp
400 89/<- %ebp 4/r32/esp
401
402 68/push 3/imm32
403 68/push 2/imm32
404 68/push 1/imm32
405 68/push 0xc/imm32/size
406 89/<- %ecx 4/r32/esp
407
408
409 68/push "1 2 3"/imm32
410 68/push Heap/imm32
411
412 e8/call parse-array-of-ints/disp32
413
414 81 0/subop/add %esp 8/imm32
415
416
417 50/push-eax
418 51/push-ecx
419
420 e8/call array-equal?/disp32
421
422 81 0/subop/add %esp 8/imm32
423
424
425 68/push "F - test-parse-array-of-ints"/imm32
426 68/push 1/imm32/true
427 50/push-eax
428
429 e8/call check-ints-equal/disp32
430
431 81 0/subop/add %esp 0xc/imm32
432
433 89/<- %esp 5/r32/ebp
434 5d/pop-to-ebp
435 c3/return
436
437 test-parse-array-of-ints-empty:
438
439
440 55/push-ebp
441 89/<- %ebp 4/r32/esp
442
443
444 68/push ""/imm32
445 68/push Heap/imm32
446
447 e8/call parse-array-of-ints/disp32
448
449 81 0/subop/add %esp 8/imm32
450
451
452 68/push "F - test-parse-array-of-ints-empty"/imm32
453 68/push 0/imm32/size
454 ff 6/subop/push *eax
455
456 e8/call check-ints-equal/disp32
457
458 81 0/subop/add %esp 0xc/imm32
459
460 89/<- %esp 5/r32/ebp
461 5d/pop-to-ebp
462 c3/return
463
464 test-parse-array-of-ints-just-whitespace:
465
466
467 55/push-ebp
468 89/<- %ebp 4/r32/esp
469
470
471 68/push Space/imm32
472 68/push Heap/imm32
473
474 e8/call parse-array-of-ints/disp32
475
476 81 0/subop/add %esp 8/imm32
477
478
479 68/push "F - test-parse-array-of-ints-empty"/imm32
480 68/push 0/imm32/size
481 ff 6/subop/push *eax
482
483 e8/call check-ints-equal/disp32
484
485 81 0/subop/add %esp 0xc/imm32
486
487 89/<- %esp 5/r32/ebp
488 5d/pop-to-ebp
489 c3/return
490
491 test-parse-array-of-ints-extra-whitespace:
492
493 55/push-ebp
494 89/<- %ebp 4/r32/esp
495
496 68/push 3/imm32
497 68/push 2/imm32
498 68/push 1/imm32
499 68/push 0xc/imm32/size
500 89/<- %ecx 4/r32/esp
501
502
503 68/push " 1 2 3 "/imm32
504 68/push Heap/imm32
505
506 e8/call parse-array-of-ints/disp32
507
508 81 0/subop/add %esp 8/imm32
509
510
511 50/push-eax
512 51/push-ecx
513
514 e8/call array-equal?/disp32
515
516 81 0/subop/add %esp 8/imm32
517
518
519 68/push "F - test-parse-array-of-ints-extra-whitespace"/imm32
520 68/push 1/imm32/true
521 50/push-eax
522
523 e8/call check-ints-equal/disp32
524
525 81 0/subop/add %esp 0xc/imm32
526
527 89/<- %esp 5/r32/ebp
528 5d/pop-to-ebp
529 c3/return
530
531
532
533 check-array-equal:
534
535 55/push-ebp
536 89/<- %ebp 4/r32/esp
537
538 50/push-eax
539
540
541
542 ff 6/subop/push *(ebp+0xc)
543 68/push Heap/imm32
544
545 e8/call parse-array-of-ints/disp32
546
547 81 0/subop/add %esp 8/imm32
548
549 89/<- %ecx 0/r32/eax
550
551
552 51/push-ecx
553 ff 6/subop/push *(ebp+8)
554
555 e8/call array-equal?/disp32
556
557 81 0/subop/add %esp 8/imm32
558
559
560 ff 6/subop/push *(ebp+0x10)
561 68/push 1/imm32
562 50/push-eax
563
564 e8/call check-ints-equal/disp32
565
566 81 0/subop/add %esp 0xc/imm32
567 $check-array-equal:end:
568
569 58/pop-to-eax
570
571 89/<- %esp 5/r32/ebp
572 5d/pop-to-ebp
573 c3/return
574
575 test-check-array-equal:
576
577 55/push-ebp
578 89/<- %ebp 4/r32/esp
579
580 68/push 3/imm32
581 68/push 2/imm32
582 68/push 1/imm32
583 68/push 0xc/imm32/size
584 89/<- %ecx 4/r32/esp
585
586
587 68/push "F - test-check-array-equal"/imm32
588 68/push "1 2 3"/imm32
589 51/push-ecx
590
591 e8/call check-array-equal/disp32
592
593 81 0/subop/add %esp 8/imm32
594
595 89/<- %esp 5/r32/ebp
596 5d/pop-to-ebp
597 c3/return
598
599