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 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 $check-stream-equal:end:
223
224 58/pop-to-EAX
225
226 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
227 5d/pop-to-EBP
228 c3/return
229
230
231
232
233
234
235 next-stream-line-equal?:
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
273 55/push-EBP
274 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
275
276 51/push-ECX
277 52/push-EDX
278 56/push-ESI
279 57/push-EDI
280
281 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
282
283 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
284
285 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 .
286
287 31/xor 3/mod/direct 2/rm32/EDX . . . 2/r32/EDX . .
288
289 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
290 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
291 $next-stream-line-equal?:loop:
292
293 3b/compare 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
294 7d/jump-if-greater-or-equal $next-stream-line-equal?:break/disp8
295
296 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xc/disp8 .
297
298 3d/compare-EAX-and 0xa/imm32/newline
299 74/jump-if-equal $next-stream-line-equal?:break/disp8
300
301 3b/compare 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . .
302 7d/jump-if-greater-or-equal $next-stream-line-equal?:false/disp8
303
304 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 3/r32/BL 4/disp8 .
305
306 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
307 75/jump-if-not-equal $next-stream-line-equal?:false/disp8
308
309 41/increment-ECX
310
311 42/increment-EDX
312 eb/jump $next-stream-line-equal?:loop/disp8
313 $next-stream-line-equal?:break:
314
315 41/increment-ECX
316
317 3b/compare 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . .
318 7c/jump-if-lesser $next-stream-line-equal?:false/disp8
319 $next-stream-line-equal?:true:
320 b8/copy-to-EAX 1/imm32
321
322 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
323 eb/jump $next-stream-line-equal?:end/disp8
324 $next-stream-line-equal?:false:
325 b8/copy-to-EAX 0/imm32
326 $next-stream-line-equal?:end:
327
328 5f/pop-to-EDI
329 5e/pop-to-ESI
330 5a/pop-to-EDX
331 59/pop-to-ECX
332
333 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
334 5d/pop-to-EBP
335 c3/return
336
337 test-next-stream-line-equal-stops-at-newline:
338
339 55/push-EBP
340 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
341
342
343 68/push _test-stream/imm32
344
345 e8/call clear-stream/disp32
346
347 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
348
349
350 68/push "Abc\ndef"/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 "Abc"/imm32
359 68/push _test-stream/imm32
360
361 e8/call next-stream-line-equal?/disp32
362
363 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
364
365
366 68/push "F - test-next-stream-line-equal-stops-at-newline"/imm32
367 68/push 1/imm32
368 50/push-EAX
369
370 e8/call check-ints-equal/disp32
371
372 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
373
374 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
375 5d/pop-to-EBP
376 c3/return
377
378 test-next-stream-line-equal-stops-at-newline-2:
379
380 55/push-EBP
381 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
382
383
384 68/push _test-stream/imm32
385
386 e8/call clear-stream/disp32
387
388 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
389
390
391 68/push "Abc\ndef"/imm32
392 68/push _test-stream/imm32
393
394 e8/call write/disp32
395
396 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
397
398
399 68/push "def"/imm32
400 68/push _test-stream/imm32
401
402 e8/call next-stream-line-equal?/disp32
403
404 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
405
406
407 68/push "F - test-next-stream-line-equal-stops-at-newline-2"/imm32
408 68/push 0/imm32
409 50/push-EAX
410
411 e8/call check-ints-equal/disp32
412
413 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
414
415 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
416 5d/pop-to-EBP
417 c3/return
418
419 test-next-stream-line-equal-skips-newline:
420
421 55/push-EBP
422 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
423
424
425 68/push _test-stream/imm32
426
427 e8/call clear-stream/disp32
428
429 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
430
431
432 68/push "Abc\ndef\n"/imm32
433 68/push _test-stream/imm32
434
435 e8/call write/disp32
436
437 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
438
439
440 68/push "Abc"/imm32
441 68/push _test-stream/imm32
442
443 e8/call next-stream-line-equal?/disp32
444
445 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
446
447
448 68/push "def"/imm32
449 68/push _test-stream/imm32
450
451 e8/call next-stream-line-equal?/disp32
452
453 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
454
455
456 68/push "F - test-next-stream-line-equal-skips-newline"/imm32
457 68/push 1/imm32
458 50/push-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-next-stream-line-equal-handles-final-line:
469
470 55/push-EBP
471 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
472
473
474 68/push _test-stream/imm32
475
476 e8/call clear-stream/disp32
477
478 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
479
480
481 68/push "Abc\ndef"/imm32
482 68/push _test-stream/imm32
483
484 e8/call write/disp32
485
486 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
487
488
489 68/push "Abc"/imm32
490 68/push _test-stream/imm32
491
492 e8/call next-stream-line-equal?/disp32
493
494 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
495
496
497 68/push "def"/imm32
498 68/push _test-stream/imm32
499
500 e8/call next-stream-line-equal?/disp32
501
502 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
503
504
505 68/push "F - test-next-stream-line-equal-skips-newline"/imm32
506 68/push 1/imm32
507 50/push-EAX
508
509 e8/call check-ints-equal/disp32
510
511 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
512
513 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
514 5d/pop-to-EBP
515 c3/return
516
517 test-next-stream-line-equal-always-fails-after-Eof:
518
519 55/push-EBP
520 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
521
522
523 68/push _test-stream/imm32
524
525 e8/call clear-stream/disp32
526
527 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
528
529
530
531 68/push ""/imm32
532 68/push _test-stream/imm32
533
534 e8/call next-stream-line-equal?/disp32
535
536 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
537
538
539 68/push "F - test-next-stream-line-equal-always-fails-after-Eof"/imm32
540 68/push 1/imm32
541 50/push-EAX
542
543 e8/call check-ints-equal/disp32
544
545 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
546
547
548 68/push ""/imm32
549 68/push _test-stream/imm32
550
551 e8/call next-stream-line-equal?/disp32
552
553 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
554
555
556 68/push "F - test-next-stream-line-equal-always-fails-after-Eof/2"/imm32
557 68/push 1/imm32
558 50/push-EAX
559
560 e8/call check-ints-equal/disp32
561
562 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
563
564 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
565 5d/pop-to-EBP
566 c3/return
567
568
569 check-next-stream-line-equal:
570
571 55/push-EBP
572 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
573
574 50/push-EAX
575
576
577 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
578 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
579
580 e8/call next-stream-line-equal?/disp32
581
582 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
583
584
585 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
586 68/push 1/imm32
587 50/push-EAX
588
589 e8/call check-ints-equal/disp32
590
591 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
592
593 58/pop-to-EAX
594
595 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
596 5d/pop-to-EBP
597 c3/return
598
599