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