https://github.com/akkartik/mu/blob/master/subx/apps/assort.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 == code
22
23
24
25
26 Entry:
27
28
29
30
31
32
33
34 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
35
36
37 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32
38 7e/jump-if-lesser-or-equal $run-main/disp8
39
40
41 68/push "test"/imm32
42 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
43
44 e8/call kernel-string-equal?/disp32
45
46 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
47
48 3d/compare-EAX-and 1/imm32
49 75/jump-if-not-equal $run-main/disp8
50
51 e8/call run-tests/disp32
52 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
53 eb/jump $main:end/disp8
54 $run-main:
55
56
57 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
58 89/copy 3/mod/direct 0/rm32/EAX . . . 4/r32/ESP . .
59
60
61 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
62
63
64 50/push-EAX/ed
65 68/push Stderr/imm32
66 68/push Stdout/imm32
67 68/push Stdin/imm32
68
69 e8/call convert/disp32
70
71 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
72
73 bb/copy-to-EBX 0/imm32
74 $main:end:
75 b8/copy-to-EAX 1/imm32/exit
76 cd/syscall 0x80/imm8
77
78
79
80
81
82 convert:
83
84
85
86
87
88
89 55/push-EBP
90 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
91
92 51/push-ECX
93
94 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x50/imm32
95 68/push 0x50/imm32/length
96 68/push 0/imm32/read
97 68/push 0/imm32/write
98 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
99
100
101 51/push-ECX
102
103 e8/call clear-stream/disp32
104
105 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
106 $convert:read:
107
108
109 51/push-ECX
110 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
111
112 e8/call read-segments/disp32
113
114 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
115 $convert:write:
116
117
118 51/push-ECX
119 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
120
121 e8/call write-segments/disp32
122
123 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
124 $convert:end:
125
126 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x5c/imm32
127
128 59/pop-to-ECX
129
130 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
131 5d/pop-to-EBP
132 c3/return
133
134 test-convert:
135
136 55/push-EBP
137 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
138
139
140
141 68/push _test-input-stream/imm32
142
143 e8/call clear-stream/disp32
144
145 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
146
147
148 b8/copy-to-EAX _test-input-buffered-file/imm32
149 05/add-to-EAX 4/imm32
150 50/push-EAX
151
152 e8/call clear-stream/disp32
153
154 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
155
156
157 68/push _test-output-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 b8/copy-to-EAX _test-output-buffered-file/imm32
165 05/add-to-EAX 4/imm32
166 50/push-EAX
167
168 e8/call clear-stream/disp32
169
170 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 68/push "# comment 1\n"/imm32
189 68/push _test-input-stream/imm32
190
191 e8/call write/disp32
192
193 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
194
195
196 68/push " # comment 2 indented\n"/imm32
197 68/push _test-input-stream/imm32
198
199 e8/call write/disp32
200
201 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
202
203
204 68/push "== code\n"/imm32
205 68/push _test-input-stream/imm32
206
207 e8/call write/disp32
208
209 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
210
211
212 68/push "# comment 3 inside a segment\n"/imm32
213 68/push _test-input-stream/imm32
214
215 e8/call write/disp32
216
217 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
218
219
220 68/push "1\n"/imm32
221 68/push _test-input-stream/imm32
222
223 e8/call write/disp32
224
225 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
226
227
228 68/push "\n"/imm32
229 68/push _test-input-stream/imm32
230
231 e8/call write/disp32
232
233 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
234
235
236 68/push "2 3 # comment 4 inline with other contents\n"/imm32
237 68/push _test-input-stream/imm32
238
239 e8/call write/disp32
240
241 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
242
243
244 68/push "== data\n"/imm32
245 68/push _test-input-stream/imm32
246
247 e8/call write/disp32
248
249 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
250
251
252 68/push "4 5/imm32\n"/imm32
253 68/push _test-input-stream/imm32
254
255 e8/call write/disp32
256
257 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
258
259
260 68/push "== code\n"/imm32
261 68/push _test-input-stream/imm32
262
263 e8/call write/disp32
264
265 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
266
267
268 68/push "6 7\n"/imm32
269 68/push _test-input-stream/imm32
270
271 e8/call write/disp32
272
273 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
274
275
276 68/push "8 9\n"/imm32
277 68/push _test-input-stream/imm32
278
279 e8/call write/disp32
280
281 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
282
283
284 68/push "== code\n"/imm32
285 68/push _test-input-stream/imm32
286
287 e8/call write/disp32
288
289 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
290
291
292 68/push "10 11\n"/imm32
293 68/push _test-input-stream/imm32
294
295 e8/call write/disp32
296
297 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
298
299
300 68/push _test-output-buffered-file/imm32
301 68/push _test-input-buffered-file/imm32
302
303 e8/call convert/disp32
304
305 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
306
307
308
309
310
311
312
313
314
315 +-- 26 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
341
342
343 68/push _test-output-buffered-file/imm32
344
345 e8/call flush/disp32
346
347 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
348
349
350 68/push "F - test-convert/0"/imm32
351 68/push "== code"/imm32
352 68/push _test-output-stream/imm32
353
354 e8/call check-next-stream-line-equal/disp32
355
356 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
357
358
359 68/push "F - test-convert/1"/imm32
360 68/push "1"/imm32
361 68/push _test-output-stream/imm32
362
363 e8/call check-next-stream-line-equal/disp32
364
365 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
366
367
368 68/push "F - test-convert/2"/imm32
369 68/push "2 3 # comment 4 inline with other contents"/imm32
370 68/push _test-output-stream/imm32
371
372 e8/call check-next-stream-line-equal/disp32
373
374 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
375
376
377 68/push "F - test-convert/3"/imm32
378 68/push "6 7"/imm32
379 68/push _test-output-stream/imm32
380
381 e8/call check-next-stream-line-equal/disp32
382
383 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
384
385
386 68/push "F - test-convert/4"/imm32
387 68/push "8 9"/imm32
388 68/push _test-output-stream/imm32
389
390 e8/call check-next-stream-line-equal/disp32
391
392 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
393
394
395 68/push "F - test-convert/5"/imm32
396 68/push "10 11"/imm32
397 68/push _test-output-stream/imm32
398
399 e8/call check-next-stream-line-equal/disp32
400
401 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
402
403
404 68/push "F - test-convert/6"/imm32
405 68/push "== data"/imm32
406 68/push _test-output-stream/imm32
407
408 e8/call check-next-stream-line-equal/disp32
409
410 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
411
412
413 68/push "F - test-convert/7"/imm32
414 68/push "4 5/imm32"/imm32
415 68/push _test-output-stream/imm32
416
417 e8/call check-next-stream-line-equal/disp32
418
419 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
420
421 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
422 5d/pop-to-EBP
423 c3/return
424
425 read-segments:
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456 55/push-EBP
457 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
458
459 50/push-EAX
460 51/push-ECX
461 52/push-EDX
462 53/push-EBX
463 56/push-ESI
464
465 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x200/imm32
466 68/push 0x200/imm32/length
467 68/push 0/imm32/read
468 68/push 0/imm32/write
469 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
470
471 68/push 0/imm32/end
472 68/push 0/imm32/curr
473 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
474 $read-segments:loop:
475
476
477 51/push-ECX
478
479 e8/call clear-stream/disp32
480
481 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
482
483
484 51/push-ECX
485 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
486
487 e8/call read-line/disp32
488
489 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
490 $read-segments:check0:
491
492 81 7/subop/compare 0/mod/indirect 1/rm32/ECX . . . . . 0/imm32
493 0f 84/jump-if-equal $read-segments:break/disp32
494 +-- 26 lines: #? # dump line -----------------------------------------------------------------------------------------------------------------------------
520
521
522 52/push-EDX
523 51/push-ECX
524
525 e8/call next-word/disp32
526
527 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
528 $read-segments:check1:
529
530
531
532 52/push-EDX
533
534 e8/call slice-empty?/disp32
535
536 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
537
538 3d/compare-EAX-and 0/imm32
539 0f 85/jump-if-not-equal $read-segments:loop/disp32
540 $read-segments:check-for-comment:
541
542
543 8b/copy 0/mod/indirect 2/rm32/EDX . . . 6/r32/ESI . .
544
545 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
546 8a/copy-byte 0/mod/indirect 6/rm32/ESI . . . 0/r32/AL . .
547
548 3d/compare-EAX-and 0x23/imm32/hash
549 0f 84/jump-if-equal $read-segments:loop/disp32
550 $read-segments:check-for-segment-header:
551 +-- 42 lines: #? # dump word-slice -----------------------------------------------------------------------------------------------------------------------
593
594
595
596
597
598 68/push "=="/imm32
599 52/push-EDX
600
601 e8/call slice-equal?/disp32
602
603 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
604
605 3d/compare-EAX-and 0/imm32
606 0f 84/jump-if-equal $read-segments:regular-line/disp32
607
608
609 52/push-EDX
610 51/push-ECX
611
612 e8/call next-word/disp32
613
614 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
615 +-- 42 lines: #? # dump segment name ---------------------------------------------------------------------------------------------------------------------
657
658
659 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Segment-size/disp32
660 52/push-EDX
661 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
662
663 e8/call get-or-insert-segment/disp32
664
665 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
666
667 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
668
669 e9/jump $read-segments:loop/disp32
670 $read-segments:regular-line:
671
672
673 51/push-ECX
674
675 e8/call rewind-stream/disp32
676
677 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
678
679
680 51/push-ECX
681 53/push-EBX
682
683 e8/call write-stream/disp32
684
685 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
686
687 e9/jump $read-segments:loop/disp32
688 $read-segments:break:
689 $read-segments:end:
690
691 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x214/imm32
692
693 5e/pop-to-ESI
694 5b/pop-to-EBX
695 5a/pop-to-EDX
696 59/pop-to-ECX
697 58/pop-to-EAX
698
699 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
700 5d/pop-to-EBP
701 c3/return
702
703 write-segments:
704
705
706
707
708
709
710
711
712
713
714
715
716 55/push-EBP
717 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
718
719 50/push-EAX
720 52/push-EDX
721 56/push-ESI
722
723 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 .
724
725 8b/copy 0/mod/indirect 6/rm32/ESI . . . 2/r32/EDX . .
726
727 81 0/subop/add 3/mod/direct 6/rm32/ESI . . . . . 0xc/imm32
728
729 01/add 3/mod/direct 2/rm32/EDX . . . 6/r32/ESI . .
730 $write-segments:loop:
731
732 39/compare 3/mod/direct 6/rm32/ESI . . . 2/r32/EDX . .
733 7d/jump-if-greater-or-equal $write-segments:break/disp8
734
735 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
736
737
738
739 68/push "== "/imm32
740 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
741
742 e8/call write-buffered/disp32
743
744 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
745
746
747 50/push-EAX
748 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
749
750 e8/call write-buffered/disp32
751
752 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
753
754
755 68/push Newline/imm32
756 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
757
758 e8/call write-buffered/disp32
759
760 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
761
762 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
763
764
765 50/push-EAX
766 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
767
768 e8/call write-stream-data/disp32
769
770 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
771 $write-segments:continue:
772
773 81 0/subop/add 3/mod/direct 6/rm32/ESI . . . . . 8/imm32
774 eb/jump $write-segments:loop/disp8
775 $write-segments:break:
776
777
778 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
779
780 e8/call flush/disp32
781
782 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
783 $write-segments:end:
784
785 5e/pop-to-ESI
786 5a/pop-to-EDX
787 58/pop-to-EAX
788
789 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
790 5d/pop-to-EBP
791 c3/return
792
793
794
795
796 get-or-insert-segment:
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813 55/push-EBP
814 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
815
816 51/push-ECX
817 52/push-EDX
818 56/push-ESI
819
820 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
821
822 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 0xc/disp8 .
823
824 8b/copy 0/mod/indirect 6/rm32/ESI . . . 2/r32/EDX . .
825 8d/copy-address 0/mod/indirect 4/rm32/sib 1/base/ECX 2/index/EDX . 2/r32/EDX . .
826 $get-or-insert-segment:search-loop:
827
828 39/compare 3/mod/direct 1/rm32/ECX . . . 2/r32/EDX . .
829 7d/jump-if-greater-or-equal $get-or-insert-segment:not-found/disp8
830
831
832
833 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
834 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
835
836 e8/call slice-equal?/disp32
837
838 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
839
840 3d/compare-EAX-and 0/imm32
841 74/jump-if-equal $get-or-insert-segment:mismatch/disp8
842 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
843 eb/jump $get-or-insert-segment:end/disp8
844 $get-or-insert-segment:mismatch:
845
846 81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 8/imm32
847
848 eb/jump $get-or-insert-segment:search-loop/disp8
849 $get-or-insert-segment:not-found:
850
851 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
852
853 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
854 3b/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 .
855 7d/jump-if-greater-or-equal $get-or-insert-segment:abort/disp8
856
857
858
859 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
860 68/push Heap/imm32
861
862 e8/call slice-to-string/disp32
863
864 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
865
866 89/copy 0/mod/indirect 2/rm32/EDX . . . 0/r32/EAX . .
867
868
869 68/push 1/imm32
870 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
871 68/push Heap/imm32
872
873 e8/call new-stream/disp32
874
875 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
876
877 89/copy 1/mod/*+disp8 2/rm32/EDX . . . 0/r32/EAX 4/disp8 .
878
879 81 0/subop/add 0/mod/indirect 6/rm32/ESI . . . . . 8/imm32
880 $get-or-insert-segment:end:
881
882 5e/pop-to-ESI
883 5a/pop-to-EDX
884 59/pop-to-ECX
885
886 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
887 5d/pop-to-EBP
888 c3/return
889
890 $get-or-insert-segment:abort:
891
892
893 68/push "get-or-insert-segment: too many segments"/imm32
894 68/push 2/imm32/stderr
895
896 e8/call _write/disp32
897
898 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
899
900 bb/copy-to-EBX 1/imm32
901 b8/copy-to-EAX 1/imm32/exit
902 cd/syscall 0x80/imm8
903
904
905 test-get-or-insert-segment:
906
907 55/push-EBP
908 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
909
910 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
911 68/push 0x10/imm32/length
912 68/push 0/imm32/read
913 68/push 0/imm32/write
914 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
915
916 68/push _test-code-segment-end/imm32/end
917 68/push _test-code-segment/imm32/start
918 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
919 $test-get-or-insert-segment:first-call:
920
921
922
923 68/push 0xa/imm32/segment-length
924 52/push-EDX
925 51/push-ECX
926
927 e8/call get-or-insert-segment/disp32
928
929 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
930
931 50/push-EAX
932
933 3d/compare-EAX-and 0/imm32
934 75/jump-if-not-equal $test-get-or-insert-segment:check1/disp8
935
936
937
938 68/push "F - test-get-or-insert-segment/0\n"/imm32
939 68/push 2/imm32/stderr
940
941 e8/call _write/disp32
942
943 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
944
945 ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 . . . Num-test-failures/disp32
946 e9/jump $test-get-or-insert-segment:end/disp32
947 $test-get-or-insert-segment:check1:
948
949
950 68/push "F - test-get-or-insert-segment/1"/imm32
951 68/push 0xa/imm32/segment-length
952 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 .
953
954 e8/call check-ints-equal/disp32
955
956 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
957 $test-get-or-insert-segment:check2:
958
959
960 68/push "F - test-get-or-insert-segment/2"/imm32
961 68/push 8/imm32/row-size
962 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
963
964 e8/call check-ints-equal/disp32
965
966 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
967
968
969 68/push "code"/imm32
970 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 0xc/disp8 .
971
972 e8/call string-equal?/disp32
973
974 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
975
976
977 68/push "F - test-get-or-insert-segment/3"/imm32
978 68/push 1/imm32
979 50/push-EAX
980
981 e8/call check-ints-equal/disp32
982
983 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
984 $test-get-or-insert-segment:check3:
985
986 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 0x10/disp8 .
987
988
989 68/push "F - test-get-or-insert-segment/4"/imm32
990 68/push 0xa/imm32/segment-size
991 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 .
992
993 e8/call check-ints-equal/disp32
994
995 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
996 $test-get-or-insert-segment:second-call:
997
998
999
1000 68/push 8/imm32/segment-length
1001 52/push-EDX
1002 51/push-ECX
1003
1004 e8/call get-or-insert-segment/disp32
1005
1006 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1007
1008 5a/pop-to-EDX
1009
1010
1011 68/push "F - test-get-or-insert-segment/5"/imm32
1012 52/push-EDX
1013 50/push-EAX
1014
1015 e8/call check-ints-equal/disp32
1016
1017 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1018
1019
1020
1021 68/push "F - test-get-or-insert-segment/6"/imm32
1022 68/push 8/imm32/row-size
1023 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
1024
1025 e8/call check-ints-equal/disp32
1026
1027 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1028 $test-get-or-insert-segment:third-call:
1029
1030
1031 c7 0/subop/copy 0/mod/indirect 2/rm32/EDX . . . . . _test-data-segment/imm32
1032 c7 0/subop/copy 1/mod/*+disp8 2/rm32/EDX . . . . 4/disp8 _test-data-segment-end/imm32
1033
1034
1035 68/push 8/imm32/segment-length
1036 52/push-EDX
1037 51/push-ECX
1038
1039 e8/call get-or-insert-segment/disp32
1040
1041 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1042
1043
1044
1045 68/push "F - test-get-or-insert-segment/7"/imm32
1046 68/push 0x10/imm32/two-rows
1047 ff 6/subop/push 0/mod/indirect 1/rm32/ECX . . . . . .
1048
1049 e8/call check-ints-equal/disp32
1050
1051 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1052 $test-get-or-insert-segment:end:
1053
1054 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1055 5d/pop-to-EBP
1056 c3/return
1057
1058
1059
1060 next-word:
1061
1062 55/push-EBP
1063 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1064
1065 50/push-EAX
1066 51/push-ECX
1067 56/push-ESI
1068 57/push-EDI
1069
1070 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
1071
1072 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 .
1073
1074
1075 68/push 0x20/imm32/space
1076 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
1077
1078 e8/call skip-chars-matching/disp32
1079
1080 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1081 $next-word:check0:
1082
1083
1084 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
1085
1086 3b/compare 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
1087 7c/jump-if-lesser $next-word:check-for-comment/disp8
1088
1089 c7 0/subop/copy 0/mod/direct 7/rm32/EDI . . . . . 0/imm32
1090 c7 0/subop/copy 1/mod/*+disp8 7/rm32/EDI . . . . 4/disp8 0/imm32
1091 eb/jump $next-word:end/disp8
1092 $next-word:check-for-comment:
1093
1094 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
1095 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/EAX 0xc/disp8 .
1096 89/copy 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
1097
1098
1099 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
1100 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0xc/disp8 .
1101
1102 3d/compare-EAX-and 0x23/imm32/pound
1103 75/jump-if-not-equal $next-word:regular-word/disp8
1104 $next-word:comment:
1105
1106 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
1107 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
1108 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 4/disp8 .
1109
1110 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
1111
1112 eb/jump $next-word:end/disp8
1113 $next-word:regular-word:
1114
1115
1116 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
1117
1118 e8/call skip-chars-not-matching-whitespace/disp32
1119
1120 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1121
1122 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 .
1123 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/EAX 0xc/disp8 .
1124 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 4/disp8 .
1125 $next-word:end:
1126
1127 5f/pop-to-EDI
1128 5e/pop-to-ESI
1129 59/pop-to-ECX
1130 58/pop-to-EAX
1131
1132 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1133 5d/pop-to-EBP
1134 c3/return
1135
1136 test-next-word:
1137
1138 55/push-EBP
1139 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1140
1141
1142
1143 68/push _test-stream/imm32
1144
1145 e8/call clear-stream/disp32
1146
1147 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1148
1149 68/push 0/imm32/end
1150 68/push 0/imm32/start
1151 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1152
1153
1154 68/push " ab"/imm32
1155 68/push _test-stream/imm32
1156
1157 e8/call write/disp32
1158
1159 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1160
1161
1162 51/push-ECX
1163 68/push _test-stream/imm32
1164
1165 e8/call next-word/disp32
1166
1167 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1168
1169
1170
1171 68/push "F - test-next-word: start"/imm32
1172 68/push 0xe/imm32
1173
1174 8b/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
1175 81 5/subop/subtract 3/mod/direct 0/rm32/EAX . . . . . _test-stream/imm32
1176 50/push-EAX
1177
1178 e8/call check-ints-equal/disp32
1179
1180 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1181
1182
1183
1184 68/push "F - test-next-word: end"/imm32
1185 68/push 0x10/imm32
1186
1187 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
1188 81 5/subop/subtract 3/mod/direct 0/rm32/EAX . . . . . _test-stream/imm32
1189 50/push-EAX
1190
1191 e8/call check-ints-equal/disp32
1192
1193 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1194
1195 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1196 5d/pop-to-EBP
1197 c3/return
1198
1199 test-next-word-returns-whole-comment:
1200
1201 55/push-EBP
1202 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1203
1204
1205
1206 68/push _test-stream/imm32
1207
1208 e8/call clear-stream/disp32
1209
1210 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1211
1212 68/push 0/imm32/end
1213 68/push 0/imm32/start
1214 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1215
1216
1217 68/push " # a"/imm32
1218 68/push _test-stream/imm32
1219
1220 e8/call write/disp32
1221
1222 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1223
1224
1225 51/push-ECX
1226 68/push _test-stream/imm32
1227
1228 e8/call next-word/disp32
1229
1230 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1231
1232
1233
1234 68/push "F - test-next-word-returns-whole-comment: start"/imm32
1235 68/push 0xe/imm32
1236
1237 8b/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
1238 81 5/subop/subtract 3/mod/direct 0/rm32/EAX . . . . . _test-stream/imm32
1239 50/push-EAX
1240
1241 e8/call check-ints-equal/disp32
1242
1243 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1244
1245
1246
1247 68/push "F - test-next-word-returns-whole-comment: end"/imm32
1248 68/push 0x11/imm32
1249
1250 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
1251 81 5/subop/subtract 3/mod/direct 0/rm32/EAX . . . . . _test-stream/imm32
1252 50/push-EAX
1253
1254 e8/call check-ints-equal/disp32
1255
1256 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1257
1258 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1259 5d/pop-to-EBP
1260 c3/return
1261
1262 test-next-word-returns-empty-string-on-eof:
1263
1264 55/push-EBP
1265 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1266
1267
1268
1269 68/push _test-stream/imm32
1270
1271 e8/call clear-stream/disp32
1272
1273 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1274
1275 68/push 0/imm32/end
1276 68/push 0/imm32/start
1277 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1278
1279
1280
1281 51/push-ECX
1282 68/push _test-stream/imm32
1283
1284 e8/call next-word/disp32
1285
1286 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1287
1288
1289 68/push "F - test-next-word-returns-empty-string-on-eof"/imm32
1290 68/push 0/imm32
1291
1292 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
1293 2b/subtract 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
1294 50/push-EAX
1295
1296 e8/call check-ints-equal/disp32
1297
1298 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1299
1300 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1301 5d/pop-to-EBP
1302 c3/return
1303
1304 == data
1305
1306 _test-code-segment:
1307 63/c 6f/o 64/d 65/e
1308 _test-code-segment-end:
1309
1310 _test-data-segment:
1311 64/d 61/a 74/t 61/a
1312 _test-data-segment-end:
1313
1314 Segment-size:
1315
1316 0x100/imm32/4KB
1317
1318
1319