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