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