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