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