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