https://github.com/akkartik/mu/blob/master/subx/apps/survey.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 == code
40
41
42
43
44 Entry:
45
46
47 68/push Heap/imm32
48 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Heap-size/disp32
49
50 e8/call new-segment/disp32
51
52 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
53
54
55 68/push 0x40000/imm32/256KB
56
57 e8/call initialize-trace-stream/disp32
58
59 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
60
61
62
63 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
64
65
66
67 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32
68 7e/jump-if-lesser-or-equal $run-main/disp8
69
70
71 68/push "test"/imm32
72 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
73
74 e8/call kernel-string-equal?/disp32
75
76 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
77
78 3d/compare-EAX-and 1/imm32
79 75/jump-if-not-equal $run-main/disp8
80
81 e8/call run-tests/disp32
82 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
83 eb/jump $main:end/disp8
84 $run-main:
85
86
87
88 68/push Stdout/imm32
89 68/push Stdin/imm32
90
91 e8/call convert/disp32
92
93 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
94
95
96
97
98
99
100
101
102
103 bb/copy-to-EBX 0/imm32
104 $main:end:
105 b8/copy-to-EAX 1/imm32/exit
106 cd/syscall 0x80/imm8
107
108
109
110
111
112
113
114
115 convert:
116
117
118
119
120
121
122
123
124
125
126
127 55/push-EBP
128 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
129
130 51/push-ECX
131 52/push-EDX
132 56/push-ESI
133
134 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
135 68/push 0xa0/imm32/length
136 68/push 0/imm32/read
137 68/push 0/imm32/write
138 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
139
140
141 2b/subtract 0/mod/indirect 5/rm32/.disp32 . . 4/r32/ESP Max-labels/disp32
142
143 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Max-labels/disp32
144
145 68/push 0/imm32/read
146
147 68/push 0/imm32/write
148 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
149
150
151 2b/subtract 0/mod/indirect 5/rm32/.disp32 . . 4/r32/ESP Input-size/disp32
152
153 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Input-size/disp32
154
155 68/push 0/imm32/read
156
157 68/push 0/imm32/write
158 89/copy 3/mod/direct 6/rm32/ESI . . . 4/r32/ESP . .
159 +-- 47 lines: #? # dump labels->write --------------------------------------------------------------------------------------------------------------------
206 +-- 9 lines: #? # write(2/stderr, "slurp in\n") ---------------------------------------------------------------------------------------------------------
215
216
217 56/push-ESI
218 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
219
220 e8/call slurp/disp32
221
222 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
223 +-- 46 lines: #? # dump labels->write --------------------------------------------------------------------------------------------------------------------
269 +-- 33 lines: #? # dump in -------------------------------------------------------------------------------------------------------------------------------
302 +-- 9 lines: #? # write(2/stderr, "compute-offsets\n") --------------------------------------------------------------------------------------------------
311
312
313 52/push-EDX
314 51/push-ECX
315 56/push-ESI
316
317 e8/call compute-offsets/disp32
318
319 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
320 +-- 9 lines: #? # write(2/stderr, "compute-addresses\n") ------------------------------------------------------------------------------------------------
329
330
331 52/push-EDX
332 51/push-ECX
333
334 e8/call compute-addresses/disp32
335
336 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x8/imm32
337
338
339 56/push-ESI
340
341 e8/call rewind-stream/disp32
342
343 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
344 +-- 9 lines: #? # write(2/stderr, "emit-output\n") ------------------------------------------------------------------------------------------------------
353 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
379 +-- 46 lines: #? # dump labels->write --------------------------------------------------------------------------------------------------------------------
425
426
427 52/push-EDX
428 51/push-ECX
429 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
430 56/push-ESI
431
432 e8/call emit-output/disp32
433
434 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
435
436
437 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
438
439 e8/call flush/disp32
440
441 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
442 $convert:end:
443
444 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x30a0/imm32
445
446 5e/pop-to-ESI
447 5a/pop-to-EDX
448 59/pop-to-ECX
449
450 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
451 5d/pop-to-EBP
452 c3/return
453
454 test-convert-computes-addresses:
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470 55/push-EBP
471 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
472
473
474
475 68/push _test-input-stream/imm32
476
477 e8/call clear-stream/disp32
478
479 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
480
481
482 b8/copy-to-EAX _test-input-buffered-file/imm32
483 05/add-to-EAX 4/imm32
484 50/push-EAX
485
486 e8/call clear-stream/disp32
487
488 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
489
490
491 68/push _test-output-stream/imm32
492
493 e8/call clear-stream/disp32
494
495 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
496
497
498 b8/copy-to-EAX _test-output-buffered-file/imm32
499 05/add-to-EAX 4/imm32
500 50/push-EAX
501
502 e8/call clear-stream/disp32
503
504 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
505
506
507
508 68/push "== code 0x1\n"/imm32
509 68/push _test-input-stream/imm32
510
511 e8/call write/disp32
512
513 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
514
515
516 68/push "Entry:\n"/imm32
517 68/push _test-input-stream/imm32
518
519 e8/call write/disp32
520
521 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
522
523
524 68/push "ab x/imm32\n"/imm32
525 68/push _test-input-stream/imm32
526
527 e8/call write/disp32
528
529 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
530
531
532 68/push "== data 0x1000\n"/imm32
533 68/push _test-input-stream/imm32
534
535 e8/call write/disp32
536
537 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
538
539
540 68/push "x:\n"/imm32
541 68/push _test-input-stream/imm32
542
543 e8/call write/disp32
544
545 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
546
547
548 68/push "01\n"/imm32
549 68/push _test-input-stream/imm32
550
551 e8/call write/disp32
552
553 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
554
555
556 68/push _test-output-buffered-file/imm32
557 68/push _test-input-buffered-file/imm32
558
559 e8/call convert/disp32
560
561 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
562
563 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
589
590
591 68/push "F - test-convert-computes-addresses/0"/imm32
592 68/push "label 'x' is at address 0x00001079."/imm32
593
594 e8/call check-trace-contains/disp32
595
596 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
597
598
599 68/push "F - test-convert-computes-addresses/1"/imm32
600 68/push "segment 'code' starts at address 0x00000074."/imm32
601
602 e8/call check-trace-contains/disp32
603
604 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
605
606
607 68/push "F - test-convert-computes-addresses/2"/imm32
608 68/push "segment 'code' has size 0x00000005."/imm32
609
610 e8/call check-trace-contains/disp32
611
612 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
613
614
615 68/push "F - test-convert-computes-addresses/3"/imm32
616 68/push "segment 'data' starts at address 0x00001079."/imm32
617
618 e8/call check-trace-contains/disp32
619
620 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
621
622 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
623 5d/pop-to-EBP
624 c3/return
625
626
627 == data
628
629 compute-offsets:file-offset:
630 0/imm32
631 compute-offsets:segment-offset:
632 0/imm32
633 compute-offsets:word-slice:
634 0/imm32/start
635 0/imm32/end
636 compute-offsets:segment-tmp:
637 0/imm32/start
638 0/imm32/end
639
640 == code
641
642 compute-offsets:
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697 55/push-EBP
698 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
699
700 50/push-EAX
701 51/push-ECX
702 52/push-EDX
703 53/push-EBX
704 56/push-ESI
705 57/push-EDI
706
707 31/xor 3/mod/direct 6/rm32/ESI . . . 6/r32/ESI . .
708
709 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:file-offset/disp32 0/imm32
710
711 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 0/imm32
712
713
714
715 68/push 1/imm32
716 68/push 0x200/imm32
717 68/push Heap/imm32
718
719 e8/call new-stream/disp32
720
721 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
722
723 89/copy 3/mod/direct 1/rm32/ECX . . . 0/r32/EAX . .
724 $compute-offsets:line-loop:
725
726 51/push-ECX
727 e8/call clear-stream/disp32
728
729 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
730
731 51/push-ECX
732 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
733 e8/call read-line/disp32
734
735 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
736
737 8b/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
738 3d/compare-EAX-and 0/imm32
739 0f 84/jump-if-equal $compute-offsets:break-line-loop/disp32
740 +-- 33 lines: #? # dump line -----------------------------------------------------------------------------------------------------------------------------
773 $compute-offsets:word-loop:
774
775 ba/copy-to-EDX compute-offsets:word-slice/imm32
776
777 52/push-EDX
778 51/push-ECX
779 e8/call next-word/disp32
780
781 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
782 +-- 80 lines: #? # dump word-slice and maybe curr-segment-name -------------------------------------------------------------------------------------------
862 $compute-offsets:case-empty:
863
864
865 52/push-EDX
866 e8/call slice-empty?/disp32
867
868 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
869
870 3d/compare-EAX-and 0/imm32
871 0f 85/jump-if-not-equal $compute-offsets:line-loop/disp32
872 $compute-offsets:case-comment:
873
874 68/push "#"/imm32
875 52/push-EDX
876 e8/call slice-starts-with?/disp32
877
878 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
879
880 3d/compare-EAX-and 0/imm32
881 0f 85/jump-if-not-equal $compute-offsets:line-loop/disp32
882 $compute-offsets:case-segment-header:
883
884
885 68/push "=="/imm32
886 52/push-EDX
887 e8/call slice-equal?/disp32
888
889 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
890
891 3d/compare-EAX-and 0/imm32
892 0f 84/jump-if-equal $compute-offsets:case-label/disp32
893
894 81 7/subop/compare 3/mod/direct 6/rm32/ESI . . . . . 0/imm32
895 74/jump-if-equal $compute-offsets:construct-next-segment/disp8
896
897
898 68/push 0x10/imm32/row-size
899 56/push-ESI
900 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
901
902 e8/call get-or-insert/disp32
903
904 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
905
906
907 51/push-ECX
908
909 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX compute-offsets:file-offset/disp32
910
911 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 .
912
913 29/subtract 3/mod/direct 3/rm32/EBX . . . 1/r32/ECX . .
914
915 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 8/disp8 .
916
917 59/pop-to-ECX
918
919
920 68/push "."/imm32
921 53/push-EBX
922 68/push "' has size "/imm32
923 56/push-ESI
924 68/push "segment '"/imm32
925
926 e8/call trace-sssns/disp32
927
928 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
929 $compute-offsets:construct-next-segment:
930
931 68/push compute-offsets:segment-tmp/imm32
932 51/push-ECX
933 e8/call next-word/disp32
934
935 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
936 +-- 47 lines: #? # dump curr-segment-name if not null (clobbering EAX) -----------------------------------------------------------------------------------
983 $compute-offsets:update-curr-segment-name:
984
985
986
987 68/push compute-offsets:segment-tmp/imm32
988 68/push Heap/imm32
989
990 e8/call slice-to-string/disp32
991
992 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
993
994 89/copy 3/mod/direct 6/rm32/ESI . . . 0/r32/EAX . .
995
996
997 3d/compare-EAX-and 0/imm32
998 0f 84/jump-if-equal $compute-offsets:abort/disp32
999
1000 68/push compute-offsets:segment-tmp/imm32
1001 51/push-ECX
1002 e8/call next-word/disp32
1003
1004 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1005
1006
1007 68/push compute-offsets:segment-tmp/imm32
1008 e8/call slice-empty?/disp32
1009
1010 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1011
1012 3d/compare-EAX-and 0/imm32
1013 0f 85/jump-if-not-equal $compute-offsets:abort/disp32
1014
1015
1016 68/push 0x10/imm32/row-size
1017 56/push-ESI
1018 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
1019
1020 e8/call get-or-insert/disp32
1021
1022 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1023
1024 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
1025
1026
1027 68/push compute-offsets:segment-tmp/imm32
1028 e8/call parse-hex-int/disp32
1029
1030 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1031
1032 89/copy 0/mod/indirect 3/rm32/EBX . . . 0/r32/EAX . .
1033
1034 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX compute-offsets:file-offset/disp32
1035 89/copy 1/mod/*+disp8 3/rm32/EBX . . . 0/r32/EAX 4/disp8 .
1036
1037
1038 68/push "."/imm32
1039 50/push-EAX
1040 68/push "' is at file offset "/imm32
1041 56/push-ESI
1042 68/push "segment '"/imm32
1043
1044 e8/call trace-sssns/disp32
1045
1046 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1047
1048 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . compute-offsets:segment-offset/disp32 0/imm32
1049
1050 e9/jump $compute-offsets:line-loop/disp32
1051 $compute-offsets:case-label:
1052
1053
1054
1055 52/push-EDX
1056
1057 e8/call is-label?/disp32
1058
1059 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1060
1061 3d/compare-EAX-and 0/imm32
1062 74/jump-if-equal $compute-offsets:case-default/disp8
1063
1064 ff 1/subop/decrement 1/mod/*+disp8 2/rm32/EDX . . . . 4/disp8 .
1065
1066
1067 68/push 0x10/imm32/row-size
1068 52/push-EDX
1069 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
1070
1071 e8/call leaky-get-or-insert-slice/disp32
1072
1073 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1074 $compute-offsets:save-label-offset:
1075
1076 89/copy 0/mod/indirect 0/rm32/EAX . . . 6/r32/ESI . .
1077
1078
1079 68/push "'."/imm32
1080 56/push-ESI
1081 68/push "' is in segment '"/imm32
1082 52/push-EDX
1083 68/push "label '"/imm32
1084
1085 e8/call trace-slsss/disp32
1086
1087 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1088
1089
1090 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX compute-offsets:segment-offset/disp32
1091
1092 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 4/disp8 .
1093
1094
1095 b8/copy-to-EAX compute-offsets:segment-offset/imm32
1096
1097 8b/copy 0/mod/indirect 0/rm32/EAX . . . 0/r32/EAX . .
1098
1099 68/push "."/imm32
1100 50/push-EAX
1101 68/push "' is at segment offset "/imm32
1102 52/push-EDX
1103 68/push "label '"/imm32
1104
1105 e8/call trace-slsns/disp32
1106
1107 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1108
1109 e9/jump $compute-offsets:word-loop/disp32
1110 $compute-offsets:case-default:
1111
1112
1113 52/push-EDX
1114
1115 e8/call compute-width-of-slice/disp32
1116
1117 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1118
1119 01/add 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX compute-offsets:segment-offset/disp32
1120
1121 01/add 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX compute-offsets:file-offset/disp32
1122 +-- 47 lines: #? # dump segment-offset -------------------------------------------------------------------------------------------------------------------
1169 e9/jump $compute-offsets:word-loop/disp32
1170 $compute-offsets:break-line-loop:
1171
1172
1173 68/push 0x10/imm32/row-size
1174 56/push-ESI
1175 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
1176
1177 e8/call get-or-insert/disp32
1178
1179 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1180
1181
1182 51/push-ECX
1183
1184 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX compute-offsets:file-offset/disp32
1185
1186 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 4/disp8 .
1187
1188 29/subtract 3/mod/direct 3/rm32/EBX . . . 1/r32/ECX . .
1189
1190 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 8/disp8 .
1191
1192 59/pop-to-ECX
1193
1194
1195
1196 68/push "."/imm32
1197 53/push-EBX
1198 68/push "' has size "/imm32
1199 56/push-ESI
1200 68/push "segment '"/imm32
1201
1202 e8/call trace-sssns/disp32
1203
1204 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1205 $compute-offsets:end:
1206
1207
1208 5f/pop-to-EDI
1209 5e/pop-to-ESI
1210 5b/pop-to-EBX
1211 5a/pop-to-EDX
1212 59/pop-to-ECX
1213 58/pop-to-EAX
1214
1215 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1216 5d/pop-to-EBP
1217 c3/return
1218 $compute-offsets:abort:
1219
1220
1221 68/push "'==' must be followed by segment name and segment-start\n"/imm32
1222 68/push 2/imm32/stderr
1223
1224 e8/call _write/disp32
1225
1226 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1227
1228 bb/copy-to-EBX 1/imm32
1229 b8/copy-to-EAX 1/imm32/exit
1230 cd/syscall 0x80/imm8
1231
1232
1233 test-compute-offsets:
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251 55/push-EBP
1252 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1253
1254
1255
1256 68/push _test-input-stream/imm32
1257
1258 e8/call clear-stream/disp32
1259
1260 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
1261
1262 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x20/imm32
1263 68/push 0x20/imm32/length
1264 68/push 0/imm32/read
1265 68/push 0/imm32/write
1266 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1267
1268 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x20/imm32
1269 68/push 0x20/imm32/length
1270 68/push 0/imm32/read
1271 68/push 0/imm32/write
1272 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
1273
1274
1275
1276 68/push "== code 0x1\n"/imm32
1277 68/push _test-input-stream/imm32
1278
1279 e8/call write/disp32
1280
1281 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1282
1283
1284 68/push "ab x/imm32 # skip comment\n"/imm32
1285 68/push _test-input-stream/imm32
1286
1287 e8/call write/disp32
1288
1289 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1290
1291
1292 68/push "== data 0x1000\n"/imm32
1293 68/push _test-input-stream/imm32
1294
1295 e8/call write/disp32
1296
1297 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1298
1299
1300 68/push "00\n"/imm32
1301 68/push _test-input-stream/imm32
1302
1303 e8/call write/disp32
1304
1305 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1306
1307
1308 68/push "x:\n"/imm32
1309 68/push _test-input-stream/imm32
1310
1311 e8/call write/disp32
1312
1313 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1314
1315
1316 68/push "34\n"/imm32
1317 68/push _test-input-stream/imm32
1318
1319 e8/call write/disp32
1320
1321 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1322
1323
1324 52/push-EDX
1325 51/push-ECX
1326 68/push _test-input-stream/imm32
1327
1328 e8/call compute-offsets/disp32
1329
1330 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1331 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
1357
1358
1359
1360 68/push "F - test-compute-offsets/0"/imm32
1361 68/push "segment 'code' is at file offset 0x00000000."/imm32
1362
1363 e8/call check-trace-contains/disp32
1364
1365 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1366
1367
1368 68/push "F - test-compute-offsets/1"/imm32
1369 68/push "segment 'code' has size 0x00000005."/imm32
1370
1371 e8/call check-trace-contains/disp32
1372
1373 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1374
1375
1376 68/push "F - test-compute-offsets/2"/imm32
1377 68/push "segment 'data' is at file offset 0x00000005."/imm32
1378
1379 e8/call check-trace-contains/disp32
1380
1381 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1382
1383
1384 68/push "F - test-compute-offsets/3"/imm32
1385 68/push "segment 'data' has size 0x00000002."/imm32
1386
1387 e8/call check-trace-contains/disp32
1388
1389 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1390
1391
1392 68/push "F - test-compute-offsets/4"/imm32
1393 68/push "label 'x' is in segment 'data'."/imm32
1394
1395 e8/call check-trace-contains/disp32
1396
1397 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1398
1399
1400 68/push "F - test-compute-offsets/5"/imm32
1401 68/push "label 'x' is at segment offset 0x00000001."/imm32
1402
1403 e8/call check-trace-contains/disp32
1404
1405 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1406
1407
1408 68/push "F - test-compute-offsets-maintains-labels-write-index"/imm32
1409 68/push 0x10/imm32/1-entry
1410 ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . .
1411
1412 e8/call check-ints-equal/disp32
1413
1414 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1415
1416 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1417 5d/pop-to-EBP
1418 c3/return
1419
1420 compute-addresses:
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444 55/push-EBP
1445 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1446
1447 50/push-EAX
1448 51/push-ECX
1449 52/push-EDX
1450 53/push-EBX
1451 56/push-ESI
1452 57/push-EDI
1453
1454 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
1455
1456
1457 8b/copy 0/mod/indirect 6/rm32/ESI . . . 7/r32/EDI . .
1458 c1/shift 5/subop/logic-right 3/mod/direct 7/rm32/EDI . . . . . 4/imm8
1459
1460 c1/shift 4/subop/left 3/mod/direct 7/rm32/EDI . . . . . 5/imm8
1461 81 0/subop/add 3/mod/direct 7/rm32/EDI . . . . . 0x34/imm32
1462
1463 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 0xc/disp8 .
1464
1465 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
1466 01/add 3/mod/direct 1/rm32/ECX . . . 6/r32/ESI . .
1467 $compute-addresses:segment-loop:
1468
1469 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
1470 73/jump-if-greater-or-equal-unsigned $compute-addresses:segment-break/disp8
1471
1472 01/add 1/mod/*+disp8 0/rm32/EAX . . . 7/r32/EDI 8/disp8 .
1473
1474
1475 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 2/r32/EDX 4/disp8 .
1476
1477 81 4/subop/and 3/mod/direct 2/rm32/EDX . . . . . 0xfffff000/imm32
1478
1479
1480 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 8/disp8 .
1481
1482 81 4/subop/and 3/mod/direct 3/rm32/EBX . . . . . 0x00000fff/imm32
1483
1484 09/or 3/mod/direct 2/rm32/EDX . . . 3/r32/EBX . .
1485 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 2/r32/EDX 4/disp8 .
1486
1487
1488 68/push "."/imm32
1489 52/push-EDX
1490 68/push "' starts at address "/imm32
1491 ff 6/subop/push 0/mod/indirect 0/rm32/EAX . . . . . .
1492 68/push "segment '"/imm32
1493
1494 e8/call trace-sssns/disp32
1495
1496 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1497
1498 05/add-to-EAX 0x10/imm32
1499 eb/jump $compute-addresses:segment-loop/disp8
1500 $compute-addresses:segment-break:
1501 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
1527
1528 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 .
1529
1530 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 0xc/disp8 .
1531
1532 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
1533 01/add 3/mod/direct 1/rm32/ECX . . . 6/r32/ESI . .
1534 $compute-addresses:label-loop:
1535
1536 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
1537 0f 83/jump-if-greater-or-equal-unsigned $compute-addresses:end/disp32
1538 +-- 26 lines: #? # dump lrow->key ------------------------------------------------------------------------------------------------------------------------
1564
1565 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 2/r32/EDX 4/disp8 .
1566 +-- 26 lines: #? # dump seg-name -------------------------------------------------------------------------------------------------------------------------
1592
1593
1594 50/push-EAX
1595
1596
1597 68/push 0x10/imm32/row-size
1598 52/push-EDX
1599 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
1600
1601 e8/call get/disp32
1602
1603 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1604
1605 89/copy 3/mod/direct 2/rm32/EDX . . . 0/r32/EAX . .
1606
1607 58/pop-to-EAX
1608
1609 8b/copy 0/mod/indirect 2/rm32/EDX . . . 3/r32/EBX . .
1610
1611 03/add 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 8/disp8 .
1612
1613 89/copy 1/mod/*+disp8 0/rm32/EAX . . . 3/r32/EBX 0xc/disp8 .
1614
1615
1616 68/push "."/imm32
1617 53/push-EBX
1618 68/push "' is at address "/imm32
1619 ff 6/subop/push 0/mod/indirect 0/rm32/EAX . . . . . .
1620 68/push "label '"/imm32
1621
1622 e8/call trace-sssns/disp32
1623
1624 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1625
1626 05/add-to-EAX 0x10/imm32
1627 e9/jump $compute-addresses:label-loop/disp32
1628 $compute-addresses:end:
1629
1630 5f/pop-to-EDI
1631 5e/pop-to-ESI
1632 5b/pop-to-EBX
1633 5a/pop-to-EDX
1634 59/pop-to-ECX
1635 58/pop-to-EAX
1636
1637 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1638 5d/pop-to-EBP
1639 c3/return
1640
1641 test-compute-addresses:
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659 55/push-EBP
1660 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1661
1662
1663 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
1664 68/push 0xa0/imm32/length
1665 68/push 0/imm32/read
1666 68/push 0/imm32/write
1667 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1668
1669 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32
1670 68/push 0x2000/imm32/length
1671 68/push 0/imm32/read
1672 68/push 0/imm32/write
1673 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
1674
1675 68/push 5/imm32/segment-size
1676 68/push 0/imm32/file-offset
1677 68/push 0x1000/imm32/start-address
1678 68/push "a"/imm32/segment-name
1679 51/push-ECX
1680
1681 e8/call stream-add4/disp32
1682
1683 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1684
1685 68/push 1/imm32/segment-size
1686 68/push 5/imm32/file-offset
1687 68/push 0x2018/imm32/start-address
1688 68/push "b"/imm32/segment-name
1689 51/push-ECX
1690
1691 e8/call stream-add4/disp32
1692
1693 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1694
1695 68/push 0xc/imm32/segment-size
1696 68/push 6/imm32/file-offset
1697 68/push 0x5444/imm32/start-address
1698 68/push "c"/imm32/segment-name
1699 51/push-ECX
1700
1701 e8/call stream-add4/disp32
1702
1703 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1704
1705 68/push 0/imm32/label-address
1706 68/push 3/imm32/segment-offset
1707 68/push "a"/imm32/segment-name
1708 68/push "l1"/imm32/label-name
1709 52/push-EDX
1710
1711 e8/call stream-add4/disp32
1712
1713 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1714
1715 68/push 0/imm32/label-address
1716 68/push 0/imm32/segment-offset
1717 68/push "b"/imm32/segment-name
1718 68/push "l2"/imm32/label-name
1719 52/push-EDX
1720
1721 e8/call stream-add4/disp32
1722
1723 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1724
1725
1726
1727 52/push-EDX
1728 51/push-ECX
1729
1730 e8/call compute-addresses/disp32
1731
1732 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1733
1734 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
1760
1761
1762 68/push "F - test-compute-addresses/0"/imm32
1763 68/push "segment 'a' starts at address 0x00001094."/imm32
1764
1765 e8/call check-trace-contains/disp32
1766
1767 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1768
1769
1770 68/push "F - test-compute-addresses/1"/imm32
1771 68/push "segment 'b' starts at address 0x00002099."/imm32
1772
1773 e8/call check-trace-contains/disp32
1774
1775 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1776
1777
1778 68/push "F - test-compute-addresses/2"/imm32
1779 68/push "segment 'c' starts at address 0x0000509a."/imm32
1780
1781 e8/call check-trace-contains/disp32
1782
1783 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1784
1785
1786 68/push "F - test-compute-addresses/3"/imm32
1787 68/push "label 'l1' is at address 0x00001097."/imm32
1788
1789 e8/call check-trace-contains/disp32
1790
1791 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1792
1793
1794 68/push "F - test-compute-addresses/4"/imm32
1795 68/push "label 'l2' is at address 0x00002099."/imm32
1796
1797 e8/call check-trace-contains/disp32
1798
1799 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1800
1801
1802 68/push "F - test-compute-addresses/maintains-labels-write-index"/imm32
1803 68/push 0x20/imm32/2-entries
1804 ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . .
1805
1806 e8/call check-ints-equal/disp32
1807
1808 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1809
1810 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1811 5d/pop-to-EBP
1812 c3/return
1813
1814 test-compute-addresses-large-segments:
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828 55/push-EBP
1829 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1830
1831
1832 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
1833 68/push 0xa0/imm32/length
1834 68/push 0/imm32/read
1835 68/push 0/imm32/write
1836 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
1837
1838 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32
1839 68/push 0x2000/imm32/length
1840 68/push 0/imm32/read
1841 68/push 0/imm32/write
1842 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
1843
1844 68/push 0x5604/imm32/segment-size
1845 68/push 0/imm32/file-offset
1846 68/push 0x1000/imm32/start-address
1847 68/push "a"/imm32/segment-name
1848 51/push-ECX
1849
1850 e8/call stream-add4/disp32
1851
1852 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1853
1854 68/push 1/imm32/segment-size
1855 68/push 0x5604/imm32/file-offset
1856 68/push 0x2018/imm32/start-address
1857 68/push "b"/imm32/segment-name
1858 51/push-ECX
1859
1860 e8/call stream-add4/disp32
1861
1862 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1863
1864 68/push 0/imm32/label-address
1865 68/push 3/imm32/segment-offset
1866 68/push "a"/imm32/segment-name
1867 68/push "l1"/imm32/label-name
1868 52/push-EDX
1869
1870 e8/call stream-add4/disp32
1871
1872 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
1873
1874
1875
1876 52/push-EDX
1877 51/push-ECX
1878
1879 e8/call compute-addresses/disp32
1880
1881 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1882
1883
1884
1885 68/push "F - test-compute-addresses-large-segments/0"/imm32
1886 68/push "segment 'a' starts at address 0x00001074."/imm32
1887
1888 e8/call check-trace-contains/disp32
1889
1890 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1891
1892
1893 68/push "F - test-compute-addresses-large-segments/1"/imm32
1894 68/push "segment 'b' starts at address 0x00002678."/imm32
1895
1896 e8/call check-trace-contains/disp32
1897
1898 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1899
1900
1901 68/push "F - test-compute-addresses-large-segments/3"/imm32
1902 68/push "label 'l1' is at address 0x00001077."/imm32
1903
1904 e8/call check-trace-contains/disp32
1905
1906 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
1907
1908 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1909 5d/pop-to-EBP
1910 c3/return
1911
1912 emit-output:
1913
1914
1915
1916
1917
1918 55/push-EBP
1919 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
1920 +-- 9 lines: #? # write(2/stderr, "emit-headers\n") -----------------------------------------------------------------------------------------------------
1929
1930
1931 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
1932 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
1933 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
1934
1935 e8/call emit-headers/disp32
1936
1937 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
1938 +-- 9 lines: #? # write(2/stderr, "emit-segments\n") ----------------------------------------------------------------------------------------------------
1947
1948
1949 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
1950 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
1951 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
1952 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
1953
1954 e8/call emit-segments/disp32
1955
1956 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
1957 $emit-output:end:
1958
1959 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
1960 5d/pop-to-EBP
1961 c3/return
1962
1963 emit-segments:
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019 55/push-EBP
2020 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
2021
2022 50/push-EAX
2023 51/push-ECX
2024 52/push-EDX
2025 53/push-EBX
2026 56/push-ESI
2027 57/push-EDI
2028
2029 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x200/imm32
2030 68/push 0x200/imm32/length
2031 68/push 0/imm32/read
2032 68/push 0/imm32/write
2033 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
2034
2035 68/push 0/imm32/end
2036 68/push 0/imm32/start
2037 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
2038
2039 68/push 0/imm32/end
2040 68/push 0/imm32/start
2041 89/copy 3/mod/direct 7/rm32/EDI . . . 4/r32/ESP . .
2042
2043 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
2044 $emit-segments:line-loop:
2045
2046
2047 51/push-ECX
2048
2049 e8/call clear-stream/disp32
2050
2051 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2052
2053
2054 51/push-ECX
2055 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
2056
2057 e8/call read-line/disp32
2058
2059 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2060 +-- 33 lines: #? # dump line -----------------------------------------------------------------------------------------------------------------------------
2093 $emit-segments:check-for-end-of-input:
2094
2095 81 7/subop/compare 0/mod/indirect 1/rm32/ECX . . . . . 0/imm32
2096 0f 84/jump-if-equal $emit-segments:end/disp32
2097
2098
2099
2100 51/push-ECX
2101
2102 e8/call num-bytes/disp32
2103
2104 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2105
2106 01/add 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
2107 $emit-segments:word-loop:
2108
2109
2110 52/push-EDX
2111 51/push-ECX
2112
2113 e8/call next-word/disp32
2114
2115 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2116 +-- 33 lines: #? # dump word-slice -----------------------------------------------------------------------------------------------------------------------
2149 $emit-segments:check-for-end-of-line:
2150
2151
2152
2153 52/push-EDX
2154
2155 e8/call slice-empty?/disp32
2156
2157 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2158
2159 3d/compare-EAX-and 0/imm32
2160 0f 85/jump-if-not-equal $emit-segments:next-line/disp32
2161 $emit-segments:check-for-comment:
2162
2163
2164 8b/copy 0/mod/indirect 2/rm32/EDX . . . 6/r32/ESI . .
2165
2166 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
2167 8a/copy-byte 0/mod/indirect 6/rm32/ESI . . . 0/r32/AL . .
2168
2169 3d/compare-EAX-and 0x23/imm32/hash
2170 0f 84/jump-if-equal $emit-segments:next-line/disp32
2171 $emit-segments:check-for-label:
2172
2173
2174
2175 52/push-EDX
2176
2177 e8/call is-label?/disp32
2178
2179 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2180
2181 3d/compare-EAX-and 0/imm32
2182 0f 85/jump-if-not-equal $emit-segments:line-loop/disp32
2183 $emit-segments:check-for-segment-header:
2184
2185
2186
2187 68/push "=="/imm32
2188 52/push-EDX
2189
2190 e8/call slice-equal?/disp32
2191
2192 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2193
2194 3d/compare-EAX-and 0/imm32
2195 0f 85/jump-if-not-equal $emit-segments:line-loop/disp32
2196 $emit-segments:2-character:
2197
2198
2199 8b/copy 1/mod/*+disp8 2/rm32/EDX . . . 0/r32/EAX 4/disp8 .
2200 2b/subtract 0/mod/indirect 2/rm32/EDX . . . 0/r32/EAX . .
2201
2202 3d/compare-EAX-and 2/imm32
2203 75/jump-if-not-equal $emit-segments:check-metadata/disp8
2204
2205
2206 52/push-EDX
2207 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2208
2209 e8/call write-slice-buffered/disp32
2210
2211 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2212
2213
2214 68/push " "/imm32
2215 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2216
2217 e8/call write-buffered/disp32
2218
2219 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2220
2221 e9/jump $emit-segments:word-loop/disp32
2222 $emit-segments:check-metadata:
2223
2224
2225
2226 57/push-EDI
2227 68/push 0x2f/imm32/slash
2228 ff 6/subop/push 1/mod/*+disp8 2/rm32/EDX . . . . 4/disp8 .
2229 ff 6/subop/push 0/mod/indirect 2/rm32/EDX . . . . . .
2230
2231 e8/call next-token-from-slice/disp32
2232
2233 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
2234 +-- 33 lines: #? # dump word-slice -----------------------------------------------------------------------------------------------------------------------
2267
2268
2269
2270 68/push 0x10/imm32/row-size
2271 57/push-EDI
2272 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
2273
2274 e8/call get-slice/disp32
2275
2276 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2277
2278 89/copy 3/mod/direct 6/rm32/ESI . . . 0/r32/EAX . .
2279 $emit-segments:check-global-variable:
2280 +-- 26 lines: #? # dump info->segment-name ---------------------------------------------------------------------------------------------------------------
2306
2307
2308
2309 68/push "code"/imm32
2310 ff 6/subop/push 0/mod/indirect 6/rm32/ESI . . . . . .
2311
2312 e8/call string-equal?/disp32
2313
2314 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2315
2316 3d/compare-EAX-and 0/imm32
2317 0f 85/jump-if-not-equal $emit-segments:check-code-label-for-imm8/disp32
2318 $emit-segments:check-global-variable-for-disp8:
2319
2320
2321
2322 68/push "disp8"/imm32
2323 52/push-EDX
2324
2325 e8/call has-metadata?/disp32
2326
2327 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2328
2329 3d/compare-EAX-and 0/imm32
2330 0f 85/jump-if-not-equal $emit-segments:global-variable-abort/disp32
2331 $emit-segments:check-global-variable-for-imm8:
2332
2333
2334
2335 68/push "imm8"/imm32
2336 52/push-EDX
2337
2338 e8/call has-metadata?/disp32
2339
2340 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2341
2342 3d/compare-EAX-and 0/imm32
2343 0f 85/jump-if-not-equal $emit-segments:global-variable-abort/disp32
2344 $emit-segments:emit-global-variable:
2345
2346
2347 68/push 4/imm32
2348 ff 6/subop/push 1/mod/*+disp8 6/rm32/ESI . . . . 8/disp8 .
2349 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2350
2351 e8/call emit-hex/disp32
2352
2353 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2354
2355 e9/jump $emit-segments:word-loop/disp32
2356 $emit-segments:check-code-label-for-imm8:
2357
2358
2359
2360 68/push "imm8"/imm32
2361 52/push-EDX
2362
2363 e8/call has-metadata?/disp32
2364
2365 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2366
2367 3d/compare-EAX-and 0/imm32
2368 0f 85/jump-if-not-equal $emit-segments:imm8-abort/disp32
2369 $emit-segments:check-code-label-for-imm32:
2370
2371
2372
2373 68/push "imm32"/imm32
2374 52/push-EDX
2375
2376 e8/call has-metadata?/disp32
2377
2378 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2379
2380 3d/compare-EAX-and 0/imm32
2381 74/jump-if-equal $emit-segments:check-code-label-for-disp8/disp8
2382 +-- 33 lines: #? # dump info->address --------------------------------------------------------------------------------------------------------------------
2415 $emit-segments:emit-code-label-imm32:
2416
2417
2418 68/push 4/imm32
2419 ff 6/subop/push 1/mod/*+disp8 6/rm32/ESI . . . . 8/disp8 .
2420 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2421
2422 e8/call emit-hex/disp32
2423
2424 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2425
2426 e9/jump $emit-segments:word-loop/disp32
2427 $emit-segments:check-code-label-for-disp8:
2428
2429
2430
2431 68/push "disp8"/imm32
2432 52/push-EDX
2433
2434 e8/call has-metadata?/disp32
2435
2436 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2437
2438 3d/compare-EAX-and 0/imm32
2439 74/jump-if-equal $emit-segments:check-code-label-for-disp32/disp8
2440 $emit-segments:emit-code-label-disp8:
2441
2442
2443 68/push 1/imm32
2444 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
2445 29/subtract 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
2446 50/push-EAX
2447 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2448
2449 e8/call emit-hex/disp32
2450
2451 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2452
2453 e9/jump $emit-segments:word-loop/disp32
2454 $emit-segments:check-code-label-for-disp32:
2455
2456
2457
2458 68/push "disp32"/imm32
2459 52/push-EDX
2460
2461 e8/call has-metadata?/disp32
2462
2463 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2464
2465 3d/compare-EAX-and 0/imm32
2466 0f 84/jump-if-equal $emit-segments:abort/disp32
2467 $emit-segments:emit-code-label-disp32:
2468
2469
2470 68/push 4/imm32
2471 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
2472 29/subtract 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
2473 50/push-EAX
2474 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2475
2476 e8/call emit-hex/disp32
2477
2478 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2479
2480 e9/jump $emit-segments:word-loop/disp32
2481 $emit-segments:next-line:
2482
2483
2484 68/push Newline/imm32
2485 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
2486
2487 e8/call write-buffered/disp32
2488
2489 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2490
2491 e9/jump $emit-segments:line-loop/disp32
2492 $emit-segments:end:
2493
2494 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x21c/imm32
2495
2496 5f/pop-to-EDI
2497 5e/pop-to-ESI
2498 5b/pop-to-EBX
2499 5a/pop-to-EDX
2500 59/pop-to-ECX
2501 58/pop-to-EAX
2502
2503 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
2504 5d/pop-to-EBP
2505 c3/return
2506
2507 $emit-segments:global-variable-abort:
2508
2509
2510 68/push "emit-segments: must refer to global variables with /disp32 or /imm32"/imm32
2511 68/push 2/imm32/stderr
2512
2513 e8/call _write/disp32
2514
2515 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2516
2517 bb/copy-to-EBX 1/imm32
2518 b8/copy-to-EAX 1/imm32/exit
2519 cd/syscall 0x80/imm8
2520
2521
2522 $emit-segments:imm8-abort:
2523
2524
2525 68/push "emit-segments: cannot refer to code labels with /imm8"/imm32
2526 68/push 2/imm32/stderr
2527
2528 e8/call _write/disp32
2529
2530 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2531
2532 bb/copy-to-EBX 1/imm32
2533 b8/copy-to-EAX 1/imm32/exit
2534 cd/syscall 0x80/imm8
2535
2536
2537 $emit-segments:abort:
2538
2539
2540
2541 68/push "emit-segments: missing metadata in "/imm32
2542 68/push 2/imm32/stderr
2543
2544 e8/call _write/disp32
2545
2546 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2547
2548
2549 52/push-EDX
2550 68/push Stderr/imm32
2551
2552 e8/call write-slice-buffered/disp32
2553
2554 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2555
2556
2557 68/push Stderr/imm32
2558
2559 e8/call flush/disp32
2560
2561 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2562
2563 bb/copy-to-EBX 1/imm32
2564 b8/copy-to-EAX 1/imm32/exit
2565 cd/syscall 0x80/imm8
2566
2567
2568 test-emit-segments-global-variable:
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593 55/push-EBP
2594 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
2595
2596
2597
2598 68/push _test-input-stream/imm32
2599
2600 e8/call clear-stream/disp32
2601
2602 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2603
2604
2605 68/push _test-output-stream/imm32
2606
2607 e8/call clear-stream/disp32
2608
2609 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2610
2611
2612 b8/copy-to-EAX _test-output-buffered-file/imm32
2613 05/add-to-EAX 4/imm32
2614 50/push-EAX
2615
2616 e8/call clear-stream/disp32
2617
2618 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2619
2620 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
2621 68/push 0xa0/imm32/length
2622 68/push 0/imm32/read
2623 68/push 0/imm32/write
2624 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
2625
2626 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32
2627 68/push 0x2000/imm32/length
2628 68/push 0/imm32/read
2629 68/push 0/imm32/write
2630 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
2631
2632
2633
2634 68/push "== code 0x1000\n"/imm32
2635 68/push _test-input-stream/imm32
2636
2637 e8/call write/disp32
2638
2639 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2640
2641
2642 68/push "ab cd ef gh\n"/imm32
2643 68/push _test-input-stream/imm32
2644
2645 e8/call write/disp32
2646
2647 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2648
2649
2650 68/push "ij x/disp32\n"/imm32
2651 68/push _test-input-stream/imm32
2652
2653 e8/call write/disp32
2654
2655 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2656
2657
2658 68/push "== data 0x2000\n"/imm32
2659 68/push _test-input-stream/imm32
2660
2661 e8/call write/disp32
2662
2663 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2664
2665
2666 68/push "00\n"/imm32
2667 68/push _test-input-stream/imm32
2668
2669 e8/call write/disp32
2670
2671 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2672
2673
2674 68/push "x:\n"/imm32
2675 68/push _test-input-stream/imm32
2676
2677 e8/call write/disp32
2678
2679 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2680
2681
2682 68/push "34\n"/imm32
2683 68/push _test-input-stream/imm32
2684
2685 e8/call write/disp32
2686
2687 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2688
2689 68/push 9/imm32/segment-size
2690 68/push 0/imm32/file-offset
2691 68/push 0x1074/imm32/start-address
2692 68/push "code"/imm32/segment-name
2693 51/push-ECX
2694
2695 e8/call stream-add4/disp32
2696
2697 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
2698
2699 68/push 1/imm32/segment-size
2700 68/push 5/imm32/file-offset
2701 68/push 0x2079/imm32/start-address
2702 68/push "data"/imm32/segment-name
2703 51/push-ECX
2704
2705 e8/call stream-add4/disp32
2706
2707 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
2708
2709 68/push 0x207a/imm32/label-address
2710 68/push 1/imm32/segment-offset
2711 68/push "data"/imm32/segment-name
2712 68/push "x"/imm32/label-name
2713 52/push-EDX
2714
2715 e8/call stream-add4/disp32
2716
2717 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
2718
2719
2720
2721 52/push-EDX
2722 51/push-ECX
2723 68/push _test-output-buffered-file/imm32
2724 68/push _test-input-stream/imm32
2725
2726 e8/call emit-segments/disp32
2727
2728 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
2729
2730
2731
2732 68/push _test-output-buffered-file/imm32
2733
2734 e8/call flush/disp32
2735
2736 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2737 +-- 33 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
2770
2771
2772 68/push "F - test-emit-segments-global-variable/0"/imm32
2773 68/push "ab cd ef gh "/imm32
2774 68/push _test-output-stream/imm32
2775
2776 e8/call check-next-stream-line-equal/disp32
2777
2778 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2779
2780
2781 68/push "F - test-emit-segments-global-variable/1"/imm32
2782 68/push "ij 7a 20 00 00 "/imm32
2783 68/push _test-output-stream/imm32
2784
2785 e8/call check-next-stream-line-equal/disp32
2786
2787 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2788
2789
2790 68/push "F - test-emit-segments-global-variable/2"/imm32
2791 68/push "00 "/imm32
2792 68/push _test-output-stream/imm32
2793
2794 e8/call check-next-stream-line-equal/disp32
2795
2796 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2797
2798
2799 68/push "F - test-emit-segments-global-variable/3"/imm32
2800 68/push "34 "/imm32
2801 68/push _test-output-stream/imm32
2802
2803 e8/call check-next-stream-line-equal/disp32
2804
2805 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2806
2807 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
2808 5d/pop-to-EBP
2809 c3/return
2810
2811 test-emit-segments-code-label:
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832 55/push-EBP
2833 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
2834
2835
2836
2837 68/push _test-input-stream/imm32
2838
2839 e8/call clear-stream/disp32
2840
2841 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2842
2843
2844 68/push _test-output-stream/imm32
2845
2846 e8/call clear-stream/disp32
2847
2848 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2849
2850
2851 b8/copy-to-EAX _test-output-buffered-file/imm32
2852 05/add-to-EAX 4/imm32
2853 50/push-EAX
2854
2855 e8/call clear-stream/disp32
2856
2857 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2858
2859 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
2860 68/push 0xa0/imm32/length
2861 68/push 0/imm32/read
2862 68/push 0/imm32/write
2863 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
2864
2865 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32
2866 68/push 0x2000/imm32/length
2867 68/push 0/imm32/read
2868 68/push 0/imm32/write
2869 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
2870
2871
2872
2873 68/push "== code 0x1000\n"/imm32
2874 68/push _test-input-stream/imm32
2875
2876 e8/call write/disp32
2877
2878 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2879
2880
2881 68/push "ab cd\n"/imm32
2882 68/push _test-input-stream/imm32
2883
2884 e8/call write/disp32
2885
2886 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2887
2888
2889 68/push "l1:\n"/imm32
2890 68/push _test-input-stream/imm32
2891
2892 e8/call write/disp32
2893
2894 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2895
2896
2897 68/push " ef gh\n"/imm32
2898 68/push _test-input-stream/imm32
2899
2900 e8/call write/disp32
2901
2902 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2903
2904
2905 68/push " ij l1/disp32\n"/imm32
2906 68/push _test-input-stream/imm32
2907
2908 e8/call write/disp32
2909
2910 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
2911
2912 68/push 9/imm32/segment-size
2913 68/push 0/imm32/file-offset
2914 68/push 0x1054/imm32/start-address
2915 68/push "code"/imm32/segment-name
2916 51/push-ECX
2917
2918 e8/call stream-add4/disp32
2919
2920 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
2921
2922 68/push 0x1056/imm32/label-address
2923 68/push 2/imm32/segment-offset
2924 68/push "code"/imm32/segment-name
2925 68/push "l1"/imm32/label-name
2926 52/push-EDX
2927
2928 e8/call stream-add4/disp32
2929
2930 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
2931
2932
2933
2934 52/push-EDX
2935 51/push-ECX
2936 68/push _test-output-buffered-file/imm32
2937 68/push _test-input-stream/imm32
2938
2939 e8/call emit-segments/disp32
2940
2941 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
2942
2943
2944
2945 68/push _test-output-buffered-file/imm32
2946
2947 e8/call flush/disp32
2948
2949 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
2950 +-- 33 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
2983
2984
2985 68/push "F - test-emit-segments-code-label/0"/imm32
2986 68/push "ab cd "/imm32
2987 68/push _test-output-stream/imm32
2988
2989 e8/call check-next-stream-line-equal/disp32
2990
2991 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
2992
2993
2994 68/push "F - test-emit-segments-code-label/1"/imm32
2995 68/push "ef gh "/imm32
2996 68/push _test-output-stream/imm32
2997
2998 e8/call check-next-stream-line-equal/disp32
2999
3000 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3001
3002
3003 68/push "F - test-emit-segments-code-label/2"/imm32
3004 68/push "ij f9 ff ff ff "/imm32
3005 68/push _test-output-stream/imm32
3006
3007 e8/call check-next-stream-line-equal/disp32
3008
3009 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3010
3011 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3012 5d/pop-to-EBP
3013 c3/return
3014
3015 test-emit-segments-code-label-absolute:
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036 55/push-EBP
3037 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3038
3039
3040
3041 68/push _test-input-stream/imm32
3042
3043 e8/call clear-stream/disp32
3044
3045 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3046
3047
3048 68/push _test-output-stream/imm32
3049
3050 e8/call clear-stream/disp32
3051
3052 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3053
3054
3055 b8/copy-to-EAX _test-output-buffered-file/imm32
3056 05/add-to-EAX 4/imm32
3057 50/push-EAX
3058
3059 e8/call clear-stream/disp32
3060
3061 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3062
3063 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0xa0/imm32
3064 68/push 0xa0/imm32/length
3065 68/push 0/imm32/read
3066 68/push 0/imm32/write
3067 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
3068
3069 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x2000/imm32
3070 68/push 0x2000/imm32/length
3071 68/push 0/imm32/read
3072 68/push 0/imm32/write
3073 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
3074
3075
3076
3077 68/push "== code 0x1000\n"/imm32
3078 68/push _test-input-stream/imm32
3079
3080 e8/call write/disp32
3081
3082 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3083
3084
3085 68/push "ab cd\n"/imm32
3086 68/push _test-input-stream/imm32
3087
3088 e8/call write/disp32
3089
3090 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3091
3092
3093 68/push "l1:\n"/imm32
3094 68/push _test-input-stream/imm32
3095
3096 e8/call write/disp32
3097
3098 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3099
3100
3101 68/push " ef gh\n"/imm32
3102 68/push _test-input-stream/imm32
3103
3104 e8/call write/disp32
3105
3106 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3107
3108
3109 68/push " ij l1/imm32\n"/imm32
3110 68/push _test-input-stream/imm32
3111
3112 e8/call write/disp32
3113
3114 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3115
3116 68/push 9/imm32/segment-size
3117 68/push 0/imm32/file-offset
3118 68/push 0x1054/imm32/start-address
3119 68/push "code"/imm32/segment-name
3120 51/push-ECX
3121
3122 e8/call stream-add4/disp32
3123
3124 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
3125
3126 68/push 0x1056/imm32/label-address
3127 68/push 2/imm32/segment-offset
3128 68/push "code"/imm32/segment-name
3129 68/push "l1"/imm32/label-name
3130 52/push-EDX
3131
3132 e8/call stream-add4/disp32
3133
3134 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
3135
3136
3137
3138 52/push-EDX
3139 51/push-ECX
3140 68/push _test-output-buffered-file/imm32
3141 68/push _test-input-stream/imm32
3142
3143 e8/call emit-segments/disp32
3144
3145 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x10/imm32
3146
3147
3148
3149 68/push _test-output-buffered-file/imm32
3150
3151 e8/call flush/disp32
3152
3153 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3154 +-- 33 lines: #? # dump output ---------------------------------------------------------------------------------------------------------------------------
3187
3188
3189 68/push "F - test-emit-segments-code-label-absolute/0"/imm32
3190 68/push "ab cd "/imm32
3191 68/push _test-output-stream/imm32
3192
3193 e8/call check-next-stream-line-equal/disp32
3194
3195 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3196
3197
3198 68/push "F - test-emit-segments-code-label-absolute/1"/imm32
3199 68/push "ef gh "/imm32
3200 68/push _test-output-stream/imm32
3201
3202 e8/call check-next-stream-line-equal/disp32
3203
3204 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3205
3206
3207 68/push "F - test-emit-segments-code-label-absolute/2"/imm32
3208 68/push "ij 56 10 00 00 "/imm32
3209 68/push _test-output-stream/imm32
3210
3211 e8/call check-next-stream-line-equal/disp32
3212
3213 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3214
3215 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3216 5d/pop-to-EBP
3217 c3/return
3218
3219 emit-headers:
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230 55/push-EBP
3231 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3232
3233 50/push-EAX
3234 51/push-ECX
3235 +-- 9 lines: #? # write(2/stderr, "emit-elf-header\n") --------------------------------------------------------------------------------------------------
3244
3245
3246 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
3247 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
3248 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3249
3250 e8/call emit-elf-header/disp32
3251
3252 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3253
3254 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
3255
3256 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3257
3258 8d/copy-address 1/mod/*+disp8 0/rm32/EAX . . . 0/r32/EAX 0xc/disp8 .
3259
3260 01/add 3/mod/direct 1/rm32/ECX . . . 0/r32/EAX . .
3261 $emit-headers:loop:
3262
3263 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
3264 0f 83/jump-if-greater-or-equal-unsigned $emit-headers:end/disp32
3265 +-- 69 lines: #? # dump curr-segment->name ---------------------------------------------------------------------------------------------------------------
3334 +-- 9 lines: #? # write(2/stderr, "emit-segment-header\n") ----------------------------------------------------------------------------------------------
3343
3344
3345 50/push-EAX
3346 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3347
3348 e8/call emit-elf-program-header-entry/disp32
3349
3350 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3351
3352 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0x10/imm32
3353 e9/jump $emit-headers:loop/disp32
3354 $emit-headers:end:
3355
3356 59/pop-to-ECX
3357 58/pop-to-EAX
3358
3359 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3360 5d/pop-to-EBP
3361 c3/return
3362
3363 emit-elf-header:
3364
3365
3366
3367
3368
3369
3370
3371 55/push-EBP
3372 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3373
3374 50/push-EAX
3375 51/push-ECX
3376 52/push-EDX
3377
3378
3379 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0x10/disp8 .
3380
3381
3382 68/push 0x10/imm32/row-size
3383 68/push "Entry"/imm32
3384 50/push-EAX
3385
3386 e8/call get/disp32
3387
3388 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
3389
3390 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 0/r32/EAX 8/disp8 .
3391
3392 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_e_entry/disp32
3393
3394
3395 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 0xc/disp8 .
3396
3397 8b/copy 0/mod/indirect 0/rm32/EAX . . . 0/r32/EAX . .
3398
3399 b9/copy-to-ECX 0x10/imm32
3400 31/xor 3/mod/direct 2/rm32/EDX . . . 2/r32/EDX . .
3401 f7 7/subop/idiv 3/mod/direct 1/rm32/ECX . . . . . .
3402
3403 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_e_phnum/disp32
3404
3405
3406 68/push Elf_header/imm32
3407 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3408
3409 e8/call emit-hex-array/disp32
3410
3411 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3412
3413
3414 68/push "\n"/imm32
3415 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3416
3417 e8/call write-buffered/disp32
3418
3419 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3420 $emit-elf-header:end:
3421
3422 5a/pop-to-EDX
3423 59/pop-to-ECX
3424 58/pop-to-EAX
3425
3426 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3427 5d/pop-to-EBP
3428 c3/return
3429
3430 emit-elf-program-header-entry:
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445 55/push-EBP
3446 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3447
3448 50/push-EAX
3449 56/push-ESI
3450
3451 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 .
3452
3453
3454 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 8/disp8 .
3455
3456 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_p_offset/disp32
3457
3458
3459 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 .
3460
3461 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_p_vaddr/disp32
3462
3463 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_p_paddr/disp32
3464
3465
3466 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 0xc/disp8 .
3467
3468 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_p_filesz/disp32
3469
3470 89/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Elf_p_memsz/disp32
3471
3472
3473 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
3474
3475
3476 68/push "code"/imm32
3477 50/push-EAX
3478
3479 e8/call string-equal?/disp32
3480
3481 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3482
3483 3d/compare-EAX-and 0/imm32
3484 74/jump-if-equal $emit-elf-program-header-entry:data/disp8
3485
3486 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Elf_p_flags/disp32 5/imm32
3487 eb/jump $emit-elf-program-header-entry:really-emit/disp8
3488 $emit-elf-program-header-entry:data:
3489
3490 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Elf_p_flags/disp32 6/imm32
3491 $emit-elf-program-header-entry:really-emit:
3492
3493
3494 68/push Elf_program_header_entry/imm32
3495 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3496
3497 e8/call emit-hex-array/disp32
3498
3499 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3500
3501
3502 68/push "\n"/imm32
3503 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3504
3505 e8/call write-buffered/disp32
3506
3507 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3508 $emit-elf-program-header-entry:end:
3509
3510 5e/pop-to-ESI
3511 58/pop-to-EAX
3512
3513 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3514 5d/pop-to-EBP
3515 c3/return
3516
3517
3518
3519 stream-add4:
3520
3521 55/push-EBP
3522 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3523
3524 50/push-EAX
3525 51/push-ECX
3526 52/push-EDX
3527 56/push-ESI
3528
3529 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
3530
3531
3532 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
3533
3534 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
3535
3536
3537 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 2/r32/EDX 8/disp8 .
3538
3539 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 2/index/EDX . 2/r32/EDX 0xc/disp8 .
3540
3541 39/compare 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
3542 73/jump-if-greater-or-equal-unsigned $stream-add4:abort/disp8
3543
3544 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 0xc/disp8 .
3545 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3546
3547 05/add-to-EAX 4/imm32
3548
3549 39/compare 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
3550 73/jump-if-greater-or-equal-unsigned $stream-add4:abort/disp8
3551
3552 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 0x10/disp8 .
3553 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3554
3555 05/add-to-EAX 4/imm32
3556
3557 39/compare 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
3558 73/jump-if-greater-or-equal-unsigned $stream-add4:abort/disp8
3559
3560 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 0x14/disp8 .
3561 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3562
3563 05/add-to-EAX 4/imm32
3564
3565 39/compare 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
3566 73/jump-if-greater-or-equal-unsigned $stream-add4:abort/disp8
3567
3568 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 1/r32/ECX 0x18/disp8 .
3569 89/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3570
3571 81 0/subop/add 0/mod/indirect 6/rm32/ESI . . . . . 0x10/imm32
3572 $stream-add4:end:
3573
3574 5e/pop-to-ESI
3575 5a/pop-to-EDX
3576 59/pop-to-ECX
3577 58/pop-to-EAX
3578
3579 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3580 5d/pop-to-EBP
3581 c3/return
3582
3583 $stream-add4:abort:
3584
3585
3586 68/push "overflow in stream-add4\n"/imm32
3587 68/push 2/imm32/stderr
3588
3589 e8/call _write/disp32
3590
3591 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3592
3593 bb/copy-to-EBX 1/imm32
3594 b8/copy-to-EAX 1/imm32/exit
3595 cd/syscall 0x80/imm8
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605 trace-sssns:
3606
3607 55/push-EBP
3608 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3609
3610
3611 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3612 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3613
3614 e8/call write/disp32
3615
3616 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3617
3618
3619 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
3620 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3621
3622 e8/call write/disp32
3623
3624 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3625
3626
3627 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
3628 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3629
3630 e8/call write/disp32
3631
3632 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3633
3634
3635 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
3636 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3637
3638 e8/call print-int32/disp32
3639
3640 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3641
3642
3643 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x18/disp8 .
3644
3645 e8/call trace/disp32
3646
3647 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3648 $trace-sssns:end:
3649
3650 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3651 5d/pop-to-EBP
3652 c3/return
3653
3654 test-trace-sssns:
3655
3656 55/push-EBP
3657 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3658
3659
3660 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
3661 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
3662
3663
3664 68/push " e"/imm32
3665 68/push 3/imm32
3666 68/push "c "/imm32
3667 68/push "b"/imm32
3668 68/push "A"/imm32
3669
3670 e8/call trace-sssns/disp32
3671
3672 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
3673 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
3699
3700
3701 68/push "F - test-trace-sssns"/imm32
3702 68/push "Abc 0x00000003 e"/imm32
3703
3704 e8/call check-trace-contains/disp32
3705
3706 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3707
3708 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3709 5d/pop-to-EBP
3710 c3/return
3711
3712 trace-snsns:
3713
3714 55/push-EBP
3715 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3716
3717
3718 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3719 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3720
3721 e8/call write/disp32
3722
3723 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3724
3725
3726 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
3727 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3728
3729 e8/call print-int32/disp32
3730
3731 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3732
3733
3734 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
3735 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3736
3737 e8/call write/disp32
3738
3739 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3740
3741
3742 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
3743 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3744
3745 e8/call print-int32/disp32
3746
3747 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3748
3749
3750 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x18/disp8 .
3751
3752 e8/call trace/disp32
3753
3754 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3755 $trace-snsns:end:
3756
3757 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3758 5d/pop-to-EBP
3759 c3/return
3760
3761 test-trace-snsns:
3762
3763 55/push-EBP
3764 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3765
3766
3767 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
3768 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
3769
3770
3771 68/push " e"/imm32
3772 68/push 3/imm32
3773 68/push " c "/imm32
3774 68/push 2/imm32
3775 68/push "A "/imm32
3776
3777 e8/call trace-snsns/disp32
3778
3779 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
3780 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
3806
3807
3808 68/push "F - test-trace-snsns"/imm32
3809 68/push "A 0x00000002 c 0x00000003 e"/imm32
3810
3811 e8/call check-trace-contains/disp32
3812
3813 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3814
3815 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3816 5d/pop-to-EBP
3817 c3/return
3818
3819 trace-slsls:
3820
3821 55/push-EBP
3822 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3823
3824
3825 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3826 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3827
3828 e8/call write/disp32
3829
3830 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3831
3832
3833 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
3834 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3835
3836 e8/call write-slice/disp32
3837
3838 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3839
3840
3841 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
3842 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3843
3844 e8/call write/disp32
3845
3846 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3847
3848
3849 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
3850 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3851
3852 e8/call write-slice/disp32
3853
3854 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3855
3856
3857 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x18/disp8 .
3858
3859 e8/call trace/disp32
3860
3861 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3862 $trace-slsls:end:
3863
3864 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3865 5d/pop-to-EBP
3866 c3/return
3867
3868 test-trace-slsls:
3869
3870 55/push-EBP
3871 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3872
3873
3874 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
3875 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
3876
3877 b8/copy-to-EAX "b"/imm32
3878 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3879 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 .
3880 05/add-to-EAX 4/imm32
3881
3882 51/push-ECX
3883 50/push-EAX
3884 89/copy 3/mod/direct 3/rm32/EBX . . . 4/r32/ESP . .
3885
3886 b8/copy-to-EAX "d"/imm32
3887 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
3888 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 .
3889 05/add-to-EAX 4/imm32
3890
3891 51/push-ECX
3892 50/push-EAX
3893 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
3894
3895
3896 68/push "e"/imm32
3897 52/push-EDX
3898 68/push "c"/imm32
3899 53/push-EBX
3900 68/push "A"/imm32
3901
3902 e8/call trace-slsls/disp32
3903
3904 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
3905 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
3931
3932
3933 68/push "F - test-trace-slsls"/imm32
3934 68/push "Abcde"/imm32
3935
3936 e8/call check-trace-contains/disp32
3937
3938 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3939
3940 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3941 5d/pop-to-EBP
3942 c3/return
3943
3944 trace-slsns:
3945
3946 55/push-EBP
3947 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3948
3949
3950 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
3951 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3952
3953 e8/call write/disp32
3954
3955 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3956
3957
3958 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
3959 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3960
3961 e8/call write-slice/disp32
3962
3963 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3964
3965
3966 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
3967 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3968
3969 e8/call write/disp32
3970
3971 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3972
3973
3974 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
3975 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
3976
3977 e8/call print-int32/disp32
3978
3979 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
3980
3981
3982 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x18/disp8 .
3983
3984 e8/call trace/disp32
3985
3986 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
3987 $trace-slsns:end:
3988
3989 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
3990 5d/pop-to-EBP
3991 c3/return
3992
3993 test-trace-slsns:
3994
3995 55/push-EBP
3996 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
3997
3998
3999 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
4000 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
4001
4002 b8/copy-to-EAX "b"/imm32
4003 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
4004 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 .
4005 05/add-to-EAX 4/imm32
4006
4007 51/push-ECX
4008 50/push-EAX
4009 89/copy 3/mod/direct 3/rm32/EBX . . . 4/r32/ESP . .
4010
4011
4012 68/push " e"/imm32
4013 68/push 3/imm32
4014 68/push "c "/imm32
4015 53/push-EBX
4016 68/push "A"/imm32
4017
4018 e8/call trace-slsns/disp32
4019
4020 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
4021 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
4047
4048
4049 68/push "F - test-trace-slsls"/imm32
4050 68/push "Abc 0x00000003 e"/imm32
4051
4052 e8/call check-trace-contains/disp32
4053
4054 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4055
4056 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4057 5d/pop-to-EBP
4058 c3/return
4059
4060 trace-slsss:
4061
4062 55/push-EBP
4063 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4064
4065
4066 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
4067 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
4068
4069 e8/call write/disp32
4070
4071 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4072
4073
4074 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
4075 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
4076
4077 e8/call write-slice/disp32
4078
4079 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4080
4081
4082 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x10/disp8 .
4083 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
4084
4085 e8/call write/disp32
4086
4087 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4088
4089
4090 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x14/disp8 .
4091 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Trace-stream/disp32
4092
4093 e8/call write/disp32
4094
4095 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4096
4097
4098 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0x18/disp8 .
4099
4100 e8/call trace/disp32
4101
4102 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4103 $trace-slsss:end:
4104
4105 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4106 5d/pop-to-EBP
4107 c3/return
4108
4109 test-trace-slsss:
4110
4111 55/push-EBP
4112 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4113
4114
4115 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/EAX Trace-stream/disp32
4116 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32
4117
4118 b8/copy-to-EAX "b"/imm32
4119 8b/copy 0/mod/indirect 0/rm32/EAX . . . 1/r32/ECX . .
4120 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 4/disp8 .
4121 05/add-to-EAX 4/imm32
4122
4123 51/push-ECX
4124 50/push-EAX
4125 89/copy 3/mod/direct 3/rm32/EBX . . . 4/r32/ESP . .
4126
4127
4128 68/push "e"/imm32
4129 68/push "d"/imm32
4130 68/push "c"/imm32
4131 53/push-EBX
4132 68/push "A"/imm32
4133
4134 e8/call trace-slsss/disp32
4135
4136 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x14/imm32
4137 +-- 26 lines: #? # dump *Trace-stream --------------------------------------------------------------------------------------------------------------------
4163
4164
4165 68/push "F - test-trace-slsss"/imm32
4166 68/push "Abcde"/imm32
4167
4168 e8/call check-trace-contains/disp32
4169
4170 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4171
4172 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4173 5d/pop-to-EBP
4174 c3/return
4175
4176 num-bytes:
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193 55/push-EBP
4194 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4195
4196 51/push-ECX
4197 52/push-EDX
4198 53/push-EBX
4199
4200 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
4201
4202 68/push 0/imm32/end
4203 68/push 0/imm32/start
4204 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
4205 +-- 26 lines: #? # dump line -----------------------------------------------------------------------------------------------------------------------------
4231
4232
4233 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
4234
4235 e8/call rewind-stream/disp32
4236
4237 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4238 $num-bytes:loop:
4239
4240
4241 51/push-ECX
4242 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
4243
4244 e8/call next-word/disp32
4245
4246 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4247 +-- 46 lines: #? # dump word-slice -----------------------------------------------------------------------------------------------------------------------
4293 $num-bytes:check0:
4294
4295
4296 50/push-EAX
4297
4298
4299 51/push-ECX
4300
4301 e8/call slice-empty?/disp32
4302
4303 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4304
4305 3d/compare-EAX-and 0/imm32
4306
4307 58/pop-to-EAX
4308 75/jump-if-not-equal $num-bytes:end/disp8
4309 $num-bytes:check-for-comment:
4310
4311
4312 8b/copy 0/mod/indirect 1/rm32/ECX . . . 2/r32/EDX . .
4313
4314 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
4315 8a/copy-byte 0/mod/indirect 2/rm32/EDX . . . 3/r32/BL . .
4316
4317 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0x23/imm32/hash
4318 74/jump-if-equal $num-bytes:end/disp8
4319 $num-bytes:check-for-label:
4320
4321
4322 8b/copy 1/mod/*+disp8 1/rm32/ECX . . . 2/r32/EDX 4/disp8 .
4323
4324 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
4325 8a/copy-byte 1/mod/*+disp8 2/rm32/EDX . . . 3/r32/BL -1/disp8 .
4326
4327 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0x3a/imm32/colon
4328 74/jump-if-equal $num-bytes:end/disp8
4329 $num-bytes:check-for-segment-header:
4330
4331
4332 50/push-EAX
4333
4334
4335 68/push "=="/imm32
4336 51/push-ECX
4337
4338 e8/call slice-equal?/disp32
4339
4340 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4341
4342 3d/compare-EAX-and 0/imm32
4343
4344 58/pop-to-EAX
4345 75/jump-if-not-equal $num-bytes:end/disp8
4346 $num-bytes:loop-body:
4347
4348
4349 89/copy 3/mod/direct 2/rm32/EDX . . . 0/r32/EAX . .
4350
4351
4352 51/push-ECX
4353
4354 e8/call compute-width-of-slice/disp32
4355
4356 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4357
4358 01/add 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
4359 e9/jump $num-bytes:loop/disp32
4360 $num-bytes:end:
4361
4362
4363 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
4364
4365 e8/call rewind-stream/disp32
4366
4367 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4368
4369 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4370
4371 5b/pop-to-EBX
4372 5a/pop-to-EDX
4373 59/pop-to-ECX
4374
4375 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4376 5d/pop-to-EBP
4377 c3/return
4378
4379 test-num-bytes-handles-empty-string:
4380
4381
4382 55/push-EBP
4383 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4384
4385
4386
4387 68/push _test-input-stream/imm32
4388
4389 e8/call clear-stream/disp32
4390
4391 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4392
4393
4394 68/push _test-output-stream/imm32
4395
4396 e8/call clear-stream/disp32
4397
4398 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4399
4400
4401
4402 68/push _test-input-stream/imm32
4403
4404 e8/call num-bytes/disp32
4405
4406 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4407
4408
4409 68/push "F - test-num-bytes-handles-empty-string"/imm32
4410 68/push 0/imm32/true
4411 50/push-EAX
4412
4413 e8/call check-ints-equal/disp32
4414
4415 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4416
4417 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4418 5d/pop-to-EBP
4419 c3/return
4420
4421 test-num-bytes-ignores-comments:
4422
4423
4424 55/push-EBP
4425 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4426
4427
4428
4429 68/push _test-input-stream/imm32
4430
4431 e8/call clear-stream/disp32
4432
4433 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4434
4435
4436 68/push _test-output-stream/imm32
4437
4438 e8/call clear-stream/disp32
4439
4440 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4441
4442
4443
4444 68/push "# abcd"/imm32
4445 68/push _test-input-stream/imm32
4446
4447 e8/call write/disp32
4448
4449 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4450
4451
4452 68/push _test-input-stream/imm32
4453
4454 e8/call num-bytes/disp32
4455
4456 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4457
4458
4459 68/push "F - test-num-bytes-ignores-comments"/imm32
4460 68/push 0/imm32/true
4461 50/push-EAX
4462
4463 e8/call check-ints-equal/disp32
4464
4465 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4466
4467 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4468 5d/pop-to-EBP
4469 c3/return
4470
4471 test-num-bytes-ignores-labels:
4472
4473
4474 55/push-EBP
4475 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4476
4477
4478
4479 68/push _test-input-stream/imm32
4480
4481 e8/call clear-stream/disp32
4482
4483 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4484
4485
4486 68/push _test-output-stream/imm32
4487
4488 e8/call clear-stream/disp32
4489
4490 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4491
4492
4493
4494 68/push "ab: # cd"/imm32
4495 68/push _test-input-stream/imm32
4496
4497 e8/call write/disp32
4498
4499 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4500
4501
4502 68/push _test-input-stream/imm32
4503
4504 e8/call num-bytes/disp32
4505
4506 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4507
4508
4509 68/push "F - test-num-bytes-ignores-labels"/imm32
4510 68/push 0/imm32/true
4511 50/push-EAX
4512
4513 e8/call check-ints-equal/disp32
4514
4515 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4516
4517 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4518 5d/pop-to-EBP
4519 c3/return
4520
4521 test-num-bytes-ignores-segment-headers:
4522
4523
4524 55/push-EBP
4525 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4526
4527
4528
4529 68/push _test-input-stream/imm32
4530
4531 e8/call clear-stream/disp32
4532
4533 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4534
4535
4536 68/push _test-output-stream/imm32
4537
4538 e8/call clear-stream/disp32
4539
4540 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4541
4542
4543
4544 68/push "== ab cd"/imm32
4545 68/push _test-input-stream/imm32
4546
4547 e8/call write/disp32
4548
4549 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4550
4551
4552 68/push _test-input-stream/imm32
4553
4554 e8/call num-bytes/disp32
4555
4556 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4557
4558
4559 68/push "F - test-num-bytes-ignores-segment-headers"/imm32
4560 68/push 0/imm32/true
4561 50/push-EAX
4562
4563 e8/call check-ints-equal/disp32
4564
4565 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4566
4567 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4568 5d/pop-to-EBP
4569 c3/return
4570
4571 test-num-bytes-counts-words-by-default:
4572
4573
4574 55/push-EBP
4575 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4576
4577
4578
4579 68/push _test-input-stream/imm32
4580
4581 e8/call clear-stream/disp32
4582
4583 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4584
4585
4586 68/push _test-output-stream/imm32
4587
4588 e8/call clear-stream/disp32
4589
4590 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4591
4592
4593
4594 68/push "ab cd ef"/imm32
4595 68/push _test-input-stream/imm32
4596
4597 e8/call write/disp32
4598
4599 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4600
4601
4602 68/push _test-input-stream/imm32
4603
4604 e8/call num-bytes/disp32
4605
4606 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4607
4608
4609 68/push "F - test-num-bytes-counts-words-by-default"/imm32
4610 68/push 3/imm32/true
4611 50/push-EAX
4612
4613 e8/call check-ints-equal/disp32
4614
4615 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4616
4617 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4618 5d/pop-to-EBP
4619 c3/return
4620
4621 test-num-bytes-ignores-trailing-comment:
4622
4623
4624 55/push-EBP
4625 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4626
4627
4628
4629 68/push _test-input-stream/imm32
4630
4631 e8/call clear-stream/disp32
4632
4633 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4634
4635
4636 68/push _test-output-stream/imm32
4637
4638 e8/call clear-stream/disp32
4639
4640 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4641
4642
4643
4644 68/push "ab cd # ef"/imm32
4645 68/push _test-input-stream/imm32
4646
4647 e8/call write/disp32
4648
4649 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4650
4651
4652 68/push _test-input-stream/imm32
4653
4654 e8/call num-bytes/disp32
4655
4656 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4657
4658
4659 68/push "F - test-num-bytes-ignores-trailing-comment"/imm32
4660 68/push 2/imm32/true
4661 50/push-EAX
4662
4663 e8/call check-ints-equal/disp32
4664
4665 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4666
4667 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4668 5d/pop-to-EBP
4669 c3/return
4670
4671 test-num-bytes-handles-imm32:
4672
4673
4674 55/push-EBP
4675 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
4676
4677
4678
4679 68/push _test-input-stream/imm32
4680
4681 e8/call clear-stream/disp32
4682
4683 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4684
4685
4686 68/push _test-output-stream/imm32
4687
4688 e8/call clear-stream/disp32
4689
4690 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4691
4692
4693
4694 68/push "ab cd/imm32 ef"/imm32
4695 68/push _test-input-stream/imm32
4696
4697 e8/call write/disp32
4698
4699 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
4700
4701
4702 68/push _test-input-stream/imm32
4703
4704 e8/call num-bytes/disp32
4705
4706 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
4707
4708
4709 68/push "F - test-num-bytes-handles-imm32"/imm32
4710 68/push 6/imm32/true
4711 50/push-EAX
4712
4713 e8/call check-ints-equal/disp32
4714
4715 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
4716
4717 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
4718 5d/pop-to-EBP
4719 c3/return
4720
4721 == data
4722
4723
4724
4725
4726 Elf_header:
4727
4728 0x34/imm32
4729
4730 $e_ident:
4731 7f 45/E 4c/L 46/F
4732 01/32-bit 01/little-endian 01/file-version 00/no-os-extensions
4733 00 00 00 00 00 00 00 00
4734 $e_type:
4735 02 00
4736 $e_machine:
4737 03 00
4738 $e_version:
4739 1/imm32
4740 Elf_e_entry:
4741 0x09000000/imm32
4742 $e_phoff:
4743 0x34/imm32
4744 $e_shoff:
4745 0/imm32
4746 $e_flags:
4747 0/imm32
4748 $e_ehsize:
4749 0x34 00
4750 $e_phentsize:
4751 0x20 00
4752 Elf_e_phnum:
4753 00 00
4754 $e_shentsize:
4755 00 00
4756 $e_shnum:
4757 00 00
4758 $e_shstrndx:
4759 00 00
4760
4761
4762
4763
4764 Elf_program_header_entry:
4765
4766 0x20/imm32
4767
4768 $p_type:
4769 1/imm32/PT_LOAD
4770 Elf_p_offset:
4771 0/imm32
4772 Elf_p_vaddr:
4773 0/imm32
4774 Elf_p_paddr:
4775 0/imm32
4776 Elf_p_filesz:
4777 0/imm32
4778 Elf_p_memsz:
4779 0/imm32
4780 Elf_p_flags:
4781 6/imm32/rw-
4782 $p_align:
4783
4784
4785 0x1000/imm32
4786
4787