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