https://github.com/akkartik/mu/blob/master/subx/058stream-equal.subx
1
2
3 == code
4
5
6
7
8
9
10 e8/call run-tests/disp32
11
12 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
13 b8/copy-to-EAX 1/imm32/exit
14 cd/syscall 0x80/imm8
15
16
17 stream-data-equal?:
18
19 55/push-EBP
20 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
21
22 51/push-ECX
23 52/push-EDX
24 56/push-ESI
25 57/push-EDI
26
27 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
28
29 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
30 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 2/r32/EDX 0xc/disp8 .
31
32 81 0/subop/add 3/mod/direct 6/rm32/ESI . . . . . 0xc/imm32
33
34 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 .
35
36 39/compare 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
37 75/jump-if-not-equal $stream-data-equal?:false/disp8
38
39 81 0/subop/add 3/mod/direct 7/rm32/EDI . . . . . 4/imm32
40
41 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
42 31/xor 3/mod/direct 1/rm32/ECX . . . 1/r32/ECX . .
43 $stream-data-equal?:loop:
44
45 39/compare 3/mod/direct 6/rm32/ESI . . . 2/r32/EDX . .
46 7d/jump-if-greater-or-equal $stream-data-equal?:true/disp8
47
48 8a/copy-byte 0/mod/indirect 6/rm32/ESI . . . 0/r32/AL . .
49
50 8a/copy-byte 0/mod/indirect 7/rm32/EDI . . . 1/r32/CL . .
51
52 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
53 75/jump-if-not-equal $stream-data-equal?:false/disp8
54
55 46/increment-ESI
56
57 47/increment-EDI
58 eb/jump $stream-data-equal?:loop/disp8
59 $stream-data-equal?:false:
60 b8/copy-to-EAX 0/imm32
61 eb/jump $stream-data-equal?:end/disp8
62 $stream-data-equal?:true:
63 b8/copy-to-EAX 1/imm32
64 $stream-data-equal?:end:
65
66 5f/pop-to-EDI
67 5e/pop-to-ESI
68 5a/pop-to-EDX
69 59/pop-to-ECX
70
71 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
72 5d/pop-to-EBP
73 c3/return
74
75 test-stream-data-equal:
76
77 55/push-EBP
78 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
79
80
81 68/push _test-stream/imm32
82
83 e8/call clear-stream/disp32
84
85 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
86
87
88 68/push "Abc"/imm32
89 68/push _test-stream/imm32
90
91 e8/call write/disp32
92
93 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
94
95
96 68/push "Abc"/imm32
97 68/push _test-stream/imm32
98
99 e8/call stream-data-equal?/disp32
100
101 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
102
103
104 68/push "F - test-stream-data-equal"/imm32
105 68/push 1/imm32
106 50/push-EAX
107
108 e8/call check-ints-equal/disp32
109
110 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
111
112 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
113 5d/pop-to-EBP
114 c3/return
115
116 test-stream-data-equal-2:
117
118 55/push-EBP
119 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
120
121
122 68/push _test-stream/imm32
123
124 e8/call clear-stream/disp32
125
126 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
127
128
129 68/push "Abc"/imm32
130 68/push _test-stream/imm32
131
132 e8/call write/disp32
133
134 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
135
136
137 68/push "Abd"/imm32
138 68/push _test-stream/imm32
139
140 e8/call stream-data-equal?/disp32
141
142 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
143
144
145 68/push "F - test-stream-data-equal-2"/imm32
146 68/push 0/imm32
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-stream-data-equal-length-check:
158
159 55/push-EBP
160 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
161
162
163 68/push _test-stream/imm32
164
165 e8/call clear-stream/disp32
166
167 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
168
169
170 68/push "Abc"/imm32
171 68/push _test-stream/imm32
172
173 e8/call write/disp32
174
175 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
176
177
178 68/push "Abcd"/imm32
179 68/push _test-stream/imm32
180
181 e8/call stream-data-equal?/disp32
182
183 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
184
185
186 68/push "F - test-stream-data-equal-length-check"/imm32
187 68/push 0/imm32
188 50/push-EAX
189
190 e8/call check-ints-equal/disp32
191
192 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
193
194 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
195 5d/pop-to-EBP
196 c3/return
197
198
199 check-stream-equal:
200
201 55/push-EBP
202 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
203
204 50/push-EAX
205
206
207 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
208 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
209
210 e8/call stream-data-equal?/disp32
211
212 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
213
214
215 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
216 68/push 1/imm32
217 50/push-EAX
218
219 e8/call check-ints-equal/disp32
220
221 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
222
223 58/pop-to-EAX
224
225 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
226 5d/pop-to-EBP
227 c3/return
228
229
230
231
232
233
234 next-stream-line-equal?:
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
260
261
262
263
264
265
266
267
268
269
270
271
272 55/push-EBP
273 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
274
275 51/push-ECX
276 52/push-EDX
277 56/push-ESI
278 57/push-EDI
279
280 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
281
282 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
283
284 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 .
285
286 31/xor 3/mod/direct 2/rm32/EDX . . . 2/r32/EDX . .
287
288 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
289 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
290 $next-stream-line-equal?:loop:
291
292 3b/compare 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
293 7d/jump-if-greater-or-equal $next-stream-line-equal?:break/disp8
294
295 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xc/disp8 .
296
297 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32/newline
298 74/jump-if-equal $next-stream-line-equal?:break/disp8
299
300 3b/compare 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . .
301 7d/jump-if-greater-or-equal $next-stream-line-equal?:false/disp8
302
303 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/BL 4/disp8 .
304
305 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
306 75/jump-if-not-equal $next-stream-line-equal?:false/disp8
307
308 41/increment-ECX
309
310 42/increment-EDX
311 eb/jump $next-stream-line-equal?:loop/disp8
312 $next-stream-line-equal?:break:
313
314 41/increment-ECX
315
316 3b/compare 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . .
317 7c/jump-if-lesser $next-stream-line-equal?:false/disp8
318 $next-stream-line-equal?:true:
319 b8/copy-to-EAX 1/imm32
320
321 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
322 eb/jump $next-stream-line-equal?:end/disp8
323 $next-stream-line-equal?:false:
324 b8/copy-to-EAX 0/imm32
325 $next-stream-line-equal?:end:
326
327 5f/pop-to-EDI
328 5e/pop-to-ESI
329 5a/pop-to-EDX
330 59/pop-to-ECX
331
332 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
333 5d/pop-to-EBP
334 c3/return
335
336 test-next-stream-line-equal-stops-at-newline:
337
338 55/push-EBP
339 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
340
341
342 68/push _test-stream/imm32
343
344 e8/call clear-stream/disp32
345
346 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
347
348
349
350 68/push "Abc"/imm32
351 68/push _test-stream/imm32
352
353 e8/call write/disp32
354
355 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
356
357
358 68/push Newline/imm32
359 68/push _test-stream/imm32
360
361 e8/call write/disp32
362
363 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
364
365
366 68/push "def"/imm32
367 68/push _test-stream/imm32
368
369 e8/call write/disp32
370
371 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
372
373
374 68/push "Abc"/imm32
375 68/push _test-stream/imm32
376
377 e8/call next-stream-line-equal?/disp32
378
379 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
380
381
382 68/push "F - test-next-stream-line-equal-stops-at-newline"/imm32
383 68/push 1/imm32
384 50/push-EAX
385
386 e8/call check-ints-equal/disp32
387
388 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
389
390 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
391 5d/pop-to-EBP
392 c3/return
393
394 test-next-stream-line-equal-stops-at-newline-2:
395
396 55/push-EBP
397 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
398
399
400 68/push _test-stream/imm32
401
402 e8/call clear-stream/disp32
403
404 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
405
406
407
408 68/push "Abc"/imm32
409 68/push _test-stream/imm32
410
411 e8/call write/disp32
412
413 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
414
415
416 68/push Newline/imm32
417 68/push _test-stream/imm32
418
419 e8/call write/disp32
420
421 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
422
423
424 68/push "def"/imm32
425 68/push _test-stream/imm32
426
427 e8/call write/disp32
428
429 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
430
431
432 68/push "def"/imm32
433 68/push _test-stream/imm32
434
435 e8/call next-stream-line-equal?/disp32
436
437 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
438
439
440 68/push "F - test-next-stream-line-equal-stops-at-newline-2"/imm32
441 68/push 0/imm32
442 50/push-EAX
443
444 e8/call check-ints-equal/disp32
445
446 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
447
448 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
449 5d/pop-to-EBP
450 c3/return
451
452 test-next-stream-line-equal-skips-newline:
453
454 55/push-EBP
455 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
456
457
458 68/push _test-stream/imm32
459
460 e8/call clear-stream/disp32
461
462 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
463
464
465
466 68/push "Abc"/imm32
467 68/push _test-stream/imm32
468
469 e8/call write/disp32
470
471 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
472
473
474 68/push Newline/imm32
475 68/push _test-stream/imm32
476
477 e8/call write/disp32
478
479 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
480
481
482 68/push "def"/imm32
483 68/push _test-stream/imm32
484
485 e8/call write/disp32
486
487 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
488
489
490 68/push Newline/imm32
491 68/push _test-stream/imm32
492
493 e8/call write/disp32
494
495 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
496
497
498 68/push "Abc"/imm32
499 68/push _test-stream/imm32
500
501 e8/call next-stream-line-equal?/disp32
502
503 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
504
505
506 68/push "def"/imm32
507 68/push _test-stream/imm32
508
509 e8/call next-stream-line-equal?/disp32
510
511 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
512
513
514 68/push "F - test-next-stream-line-equal-skips-newline"/imm32
515 68/push 1/imm32
516 50/push-EAX
517
518 e8/call check-ints-equal/disp32
519
520 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
521
522 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
523 5d/pop-to-EBP
524 c3/return
525
526 test-next-stream-line-equal-handles-final-line:
527
528 55/push-EBP
529 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
530
531
532 68/push _test-stream/imm32
533
534 e8/call clear-stream/disp32
535
536 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
537
538
539
540 68/push "Abc"/imm32
541 68/push _test-stream/imm32
542
543 e8/call write/disp32
544
545 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
546
547
548 68/push Newline/imm32
549 68/push _test-stream/imm32
550
551 e8/call write/disp32
552
553 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
554
555
556 68/push "def"/imm32
557 68/push _test-stream/imm32
558
559 e8/call write/disp32
560
561 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
562
563
564 68/push "Abc"/imm32
565 68/push _test-stream/imm32
566
567 e8/call next-stream-line-equal?/disp32
568
569 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
570
571
572 68/push "def"/imm32
573 68/push _test-stream/imm32
574
575 e8/call next-stream-line-equal?/disp32
576
577 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
578
579
580 68/push "F - test-next-stream-line-equal-skips-newline"/imm32
581 68/push 1/imm32
582 50/push-EAX
583
584 e8/call check-ints-equal/disp32
585
586 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
587
588 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
589 5d/pop-to-EBP
590 c3/return
591
592 test-next-stream-line-equal-always-fails-after-eof:
593
594 55/push-EBP
595 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
596
597
598 68/push _test-stream/imm32
599
600 e8/call clear-stream/disp32
601
602 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
603
604
605
606 68/push ""/imm32
607 68/push _test-stream/imm32
608
609 e8/call next-stream-line-equal?/disp32
610
611 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
612
613
614 68/push "F - test-next-stream-line-equal-always-fails-after-eof"/imm32
615 68/push 1/imm32
616 50/push-EAX
617
618 e8/call check-ints-equal/disp32
619
620 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
621
622
623 68/push ""/imm32
624 68/push _test-stream/imm32
625
626 e8/call next-stream-line-equal?/disp32
627
628 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
629
630
631 68/push "F - test-next-stream-line-equal-always-fails-after-eof/2"/imm32
632 68/push 1/imm32
633 50/push-EAX
634
635 e8/call check-ints-equal/disp32
636
637 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
638
639 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
640 5d/pop-to-EBP
641 c3/return
642
643
644 check-next-stream-line-equal:
645
646 55/push-EBP
647 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
648
649 50/push-EAX
650
651
652 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
653 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
654
655 e8/call next-stream-line-equal?/disp32
656
657 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
658
659
660 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
661 68/push 1/imm32
662 50/push-EAX
663
664 e8/call check-ints-equal/disp32
665
666 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
667
668 58/pop-to-EAX
669
670 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
671 5d/pop-to-EBP
672 c3/return