https://github.com/akkartik/mu/blob/master/subx/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