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