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