Motorola M6800 (6800) Exorciser / SWTPC emulator plus 6801 instruction set emulation
Revision | b9eccc1dff00d671d111e4edf3834da799bba959 (tree) |
---|---|
Time | 2020-11-16 00:16:42 |
Author | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
unasm now has 6801 stuff and is lightly tested, adding test code to
repository,
fig-forth model for 6801 progressing well?
@@ -0,0 +1,118 @@ | ||
1 | + OPT PRT | |
2 | + OPT 6801 | |
3 | + | |
4 | + ORG $80 | |
5 | +N RMB 4 | |
6 | +DPTBL RMB 4 | |
7 | + | |
8 | + ORG $A0 | |
9 | +USTARS TSX dodge return address | |
10 | + LDD 2,X multiplier | |
11 | + STD N | |
12 | + LDD 4,X multiplicand | |
13 | + STD N+2 | |
14 | + LDA B N multiplier high | |
15 | + MUL | |
16 | + STD 2,X result high cell | |
17 | + LDA B N+1 multiplier low | |
18 | + LDA A N+3 multiplicand low | |
19 | + MUL | |
20 | + STD 4,X result low cell | |
21 | + LDA B N+1 multiplier low | |
22 | + LDA A N+2 multiplicand high | |
23 | + MUL inner 1 | |
24 | + ADDD 3,X | |
25 | + STD 3,X | |
26 | + BCC USTAS2 | |
27 | + INC 2,X | |
28 | +USTAS2 LDA B N multiplier high | |
29 | + LDA A N+3 multiplicand low | |
30 | + MUL inner 2 | |
31 | + ADDD 3,X | |
32 | + STD 3,X | |
33 | + BCC USTASD | |
34 | + INC 2,X | |
35 | +USTASD RTS | |
36 | + | |
37 | + | |
38 | +STKSZ EQU $80 | |
39 | +GLOBALSZ EQU $10 | |
40 | + | |
41 | + | |
42 | + ORG $220 | |
43 | + FCC "help me, I think I'm falling into the sea." | |
44 | + FCC "wouldn't want to go there by myself, that's such a lonely place to be." | |
45 | + | |
46 | + ORG $340 | |
47 | + FCB 0,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 | |
48 | + | |
49 | + | |
50 | + | |
51 | + ORG $7800 | |
52 | +GLOBAL RMB GLOBALSZ | |
53 | + | |
54 | + ORG $8000 | |
55 | +RAMBAR EQU * | |
56 | + | |
57 | + ORG $100 | |
58 | +START LDS #RAMBAR-STKSZ | |
59 | + LDX #$188 | |
60 | + PSHX | |
61 | + LDAB #167 | |
62 | + ABX | |
63 | + NOP | |
64 | + LDD 3,X | |
65 | + BRN START | |
66 | + LDD #$1234 | |
67 | + ADDD #$FEDC | |
68 | + SUBD #$FEDC | |
69 | + LDAA #10 | |
70 | + LDAB #25 | |
71 | + MUL | |
72 | + PSHB | |
73 | + PSHA | |
74 | + LDD #1001 | |
75 | + PSHB | |
76 | + PSHA | |
77 | + JSR USTARS | |
78 | + TSX | |
79 | + LDD 0,X | |
80 | + LSRD | |
81 | + STD 0,X | |
82 | + ROR 2,X | |
83 | + ROR 3,X | |
84 | + LDD 2,X | |
85 | + ASLD | |
86 | + ROL 1,X | |
87 | + ROL 0,X | |
88 | + STD 2,X | |
89 | + SUBD 0,X | |
90 | + LDX 4,X | |
91 | + LDAB #$F8 | |
92 | + ABX | |
93 | + LDAB #96 | |
94 | + ABX | |
95 | + LDAA $11,X | |
96 | + INX | |
97 | + INX | |
98 | + INX | |
99 | + INX | |
100 | + INX | |
101 | + CMPA 12,X | |
102 | + BNE STOP | |
103 | + NOP | |
104 | + CPX #$345 | |
105 | + INS | |
106 | + INS | |
107 | + INS | |
108 | + INS | |
109 | + PULX | |
110 | + CPX #$345 | |
111 | + BCC START | |
112 | + NOP | |
113 | + NOP | |
114 | +STOP WAIT | |
115 | + | |
116 | + | |
117 | + | |
118 | + ORG START |
@@ -648,25 +648,22 @@ DIGIT2 CLR B | ||
648 | 648 | * " |
649 | 649 | * " |
650 | 650 | * |
651 | +PD EQU N ptr to dict word being checked | |
652 | +PA0 EQU N+2 | |
653 | +PA EQU N+4 | |
654 | +PC EQU N+6 | |
655 | +* | |
651 | 656 | * ======>> 11 << |
652 | 657 | FCB $86 |
653 | 658 | FCC 5,(FIND) |
654 | 659 | FCB $A9 |
655 | 660 | FDB DIGIT-8 |
656 | 661 | PFIND FDB *+2 |
657 | - NOP | |
658 | - NOP | |
659 | -PD EQU N ptr to dict word being checked | |
660 | -PA0 EQU N+2 | |
661 | -PA EQU N+4 | |
662 | -PC EQU N+6 | |
663 | - LDX #PD | |
664 | - LDA B #4 | |
665 | -PFIND0 PUL A loop to get arguments | |
666 | - STA A 0,X | |
667 | - INX | |
668 | - DEC B | |
669 | - BNE PFIND0 | |
662 | + TSX | |
663 | + LDD 0,X | |
664 | + STD PD | |
665 | + LDD 2,X | |
666 | + STD PA0 | |
670 | 667 | * |
671 | 668 | LDX PD |
672 | 669 | PFIND1 LDA B 0,X get count dict count |
@@ -698,9 +695,12 @@ PFIND3 LDX 0,X get new link | ||
698 | 695 | * |
699 | 696 | * not found : |
700 | 697 | * |
698 | + INS | |
699 | + INS | |
700 | + TSX | |
701 | 701 | CLR A |
702 | 702 | CLR B |
703 | - JMP PUSHBA | |
703 | + JMP STABX | |
704 | 704 | PFIND8 CBA |
705 | 705 | BEQ PFIND2 |
706 | 706 | PFIND4 LDX PD |
@@ -711,22 +711,13 @@ PFIND9 LDA B 0,X scan forward to end of this name | ||
711 | 711 | * |
712 | 712 | * found : |
713 | 713 | * |
714 | -FOUND LDA A PD compute CFA | |
715 | - LDA B PD+1 | |
716 | - ADD B #4 | |
717 | - ADC A #0 | |
718 | - PSH B | |
719 | - PSH A | |
720 | - LDA A PC | |
721 | - PSH A | |
722 | - CLR A | |
723 | - PSH A | |
724 | - LDA B #1 | |
725 | - JMP PUSHBA | |
726 | -* | |
727 | - PSH A | |
714 | +FOUND TSX | |
715 | + LDD PD compute CFA | |
716 | + ADDD #4 | |
717 | + STD 2,X | |
718 | + LDA B PC | |
728 | 719 | CLR A |
729 | - PSH A | |
720 | + STD 0,X | |
730 | 721 | LDA B #1 |
731 | 722 | JMP PUSHBA |
732 | 723 | * |
@@ -745,7 +736,7 @@ ENCLOS FDB *+2 | ||
745 | 736 | PUL B now, get the low byte, for an 8-bit delimiter |
746 | 737 | TSX |
747 | 738 | LDX 0,X |
748 | - CLR N | |
739 | + CLR N Buffer must be less than 256 bytes! | |
749 | 740 | * wait for a non-delimiter or a NUL |
750 | 741 | ENCL2 LDA A 0,X |
751 | 742 | BEQ ENCL6 |
@@ -801,7 +792,7 @@ ENCL8 LDA B N save NC | ||
801 | 792 | FCB $D4 |
802 | 793 | FDB ENCLOS-10 |
803 | 794 | EMIT FDB *+2 |
804 | - PUL A | |
795 | + INS | |
805 | 796 | PUL A |
806 | 797 | JSR PEMIT |
807 | 798 | LDX UP |
@@ -847,20 +838,20 @@ CR FDB *+2 | ||
847 | 838 | FCC 4,CMOVE source, destination, count |
848 | 839 | FCB $C5 |
849 | 840 | FDB CR-5 |
850 | -CMOVE FDB *+2 takes ( 43+47*count cycles ) | |
851 | - LDX #N | |
841 | +CMOVE FDB *+2 takes ( ?? count cycles ) | |
842 | + TSX move parameters to scratch area | |
843 | + LDD 0,X | |
844 | + STD N | |
845 | + LDD 2,X | |
846 | + STD N+2 | |
847 | + LDD 4,X | |
848 | + STD N+4 | |
852 | 849 | LDA B #6 |
853 | -CMOV1 PUL A | |
854 | - STA A 0,X move parameters to scratch area | |
855 | - INX | |
856 | - DEC B | |
857 | - BNE CMOV1 | |
858 | -CMOV2 LDA A N | |
859 | - LDA B N+1 | |
860 | - SUB B #1 | |
861 | - SBC A #0 | |
862 | - STA A N | |
863 | - STA B N+1 | |
850 | + ABX | |
851 | + TXS | |
852 | +CMOV2 LDD N | |
853 | + SUBD #1 | |
854 | + STD N | |
864 | 855 | BCS CMOV3 |
865 | 856 | LDX N+4 |
866 | 857 | LDA A 0,X |
@@ -880,33 +871,33 @@ CMOV3 JMP NEXT | ||
880 | 871 | FCB $AA |
881 | 872 | FDB CMOVE-8 |
882 | 873 | USTAR FDB *+2 |
883 | - BSR USTARS | |
884 | - INS | |
885 | - INS | |
886 | - JMP PUSHBA | |
887 | -* | |
888 | -* The following is a subroutine which | |
889 | -* multiplies top 2 words on stack, | |
890 | -* leaving 32-bit result: high order word in A,B | |
891 | -* low order word in 2nd word of stack. | |
892 | -* | |
893 | -USTARS LDA A #16 bits/word counter | |
894 | - PSH A | |
895 | - CLR A | |
896 | - CLR B | |
897 | 874 | TSX |
898 | -USTAR2 ROR 5,X shift multiplier | |
899 | - ROR 6,X | |
900 | - DEC 0,X done? | |
901 | - BMI USTAR4 | |
902 | - BCC USTAR3 | |
903 | - ADD B 4,X | |
904 | - ADC A 3,X | |
905 | -USTAR3 ROR A | |
906 | - ROR B shift result | |
907 | - BRA USTAR2 | |
908 | -USTAR4 INS dump counter | |
909 | - RTS | |
875 | + LDAA 1,X least | |
876 | + LDAB 3,X | |
877 | + MUL | |
878 | + STD N+2 | |
879 | + LDAA 0,X most | |
880 | + LDAB 2,X | |
881 | + MUL | |
882 | + STD N | |
883 | + LDD 1,X inner | |
884 | + MUL | |
885 | + ADDD N+1 | |
886 | + BCC USTAR1 | |
887 | + INC N | |
888 | +USTAR1 STD N+1 | |
889 | + LDAA 0,X inner | |
890 | + LDAB 3,X | |
891 | + MUL | |
892 | + ADDD N+1 | |
893 | + BCC USTAR2 | |
894 | + INC N | |
895 | +USTAR2 | |
896 | + STD N+1 | |
897 | + LDD N+2 | |
898 | + STD 2,X | |
899 | + LDD N | |
900 | + JMP STABX | |
910 | 901 | * |
911 | 902 | * ######>> screen 24 << |
912 | 903 | * ======>> 19 << |
@@ -918,32 +909,32 @@ USLASH FDB *+2 | ||
918 | 909 | LDA A #17 |
919 | 910 | PSH A |
920 | 911 | TSX |
921 | - LDA A 3,X | |
922 | - LDA B 4,X | |
923 | -USL1 CMP A 1,X | |
924 | - BHI USL3 | |
925 | - BCS USL2 | |
926 | - CMP B 2,X | |
927 | - BCC USL3 | |
928 | -USL2 CLC | |
929 | - BRA USL4 | |
930 | -USL3 SUB B 2,X | |
931 | - SBC A 1,X | |
932 | - SEC | |
933 | -USL4 ROL 6,X | |
934 | - ROL 5,X | |
912 | + LDD 3,X dividend high cell | |
913 | +USLASL SUBD 1,X try divisor against current frame | |
914 | + BCC USLASR | |
915 | + ADDD 1,X restore | |
916 | + CLC Catch potential boundary cases I don't want to think about. | |
917 | + BRA USLASN | |
918 | +USLASR SEC result bit | |
919 | +USLASN ROL 6,X shift result in behind | |
920 | + ROL 5,X shift frame right | |
935 | 921 | DEC 0,X |
936 | - BEQ USL5 | |
937 | - ROL B | |
922 | + BEQ USLASD | |
923 | + ROL B remainder/current frame | |
938 | 924 | ROL A |
939 | - BCC USL1 | |
940 | - BRA USL3 | |
941 | -USL5 INS | |
925 | + BCC USLASL Trying to pull it into range this way only works | |
926 | + SUBD 1,X if it only has to work once, AIUI. | |
927 | + BRA USLASR | |
928 | +USLASD | |
929 | + STD 1,X temporary | |
930 | + LDD 5,X quotient | |
931 | + STD 3,X top | |
932 | + LDD 1,X | |
933 | + STD 5,X remainder at 2nd | |
934 | + INS SP needs adjusting. | |
942 | 935 | INS |
943 | 936 | INS |
944 | - INS | |
945 | - INS | |
946 | - JMP SWAP+4 reverse quotient & remainder | |
937 | + JMP NEXT | |
947 | 938 | * |
948 | 939 | * ######>> screen 25 << |
949 | 940 | * ======>> 20 << |
@@ -957,7 +948,7 @@ AND FDB *+2 | ||
957 | 948 | TSX |
958 | 949 | AND B 1,X |
959 | 950 | AND A 0,X |
960 | - JMP STABX | |
951 | + JMP STABX (Uses D, gets a little speed-up.) | |
961 | 952 | * |
962 | 953 | * ======>> 21 << |
963 | 954 | FCB $82 |
@@ -993,9 +984,8 @@ XOR FDB *+2 | ||
993 | 984 | FDB XOR-6 |
994 | 985 | SPAT FDB *+2 |
995 | 986 | TSX |
996 | - STX N scratch area | |
997 | - LDX #N | |
998 | - JMP GETX | |
987 | + PSHX | |
988 | + JMP NEXT | |
999 | 989 | * |
1000 | 990 | * ======>> 24 << |
1001 | 991 | FCB $83 |
@@ -1006,7 +996,8 @@ SPSTOR FDB *+2 | ||
1006 | 996 | LDX UP |
1007 | 997 | LDX XSPZER-UORIG,X |
1008 | 998 | TXS watch it ! X and S are not equal. |
1009 | - JMP NEXT | |
999 | + JMP NEXT (Not that it matters here.) | |
1000 | +* | |
1010 | 1001 | * ======>> 25 << |
1011 | 1002 | FCB $83 |
1012 | 1003 | FCC 2,RP! |
@@ -1038,10 +1029,8 @@ SEMIS FDB *+2 | ||
1038 | 1029 | FDB SEMIS-5 |
1039 | 1030 | LEAVE FDB *+2 |
1040 | 1031 | LDX RP |
1041 | - LDA A 2,X | |
1042 | - LDA B 3,X | |
1043 | - STA A 4,X | |
1044 | - STA B 5,X | |
1032 | + LDD 2,X | |
1033 | + STD 4,X | |
1045 | 1034 | JMP NEXT |
1046 | 1035 | * |
1047 | 1036 | * ======>> 28 << |
@@ -1056,8 +1045,7 @@ TOR FDB *+2 | ||
1056 | 1045 | STX RP |
1057 | 1046 | PUL A |
1058 | 1047 | PUL B |
1059 | - STA A 2,X | |
1060 | - STA B 3,X | |
1048 | + STD 2,X | |
1061 | 1049 | JMP NEXT |
1062 | 1050 | * |
1063 | 1051 | * ======>> 29 << |
@@ -1067,8 +1055,7 @@ TOR FDB *+2 | ||
1067 | 1055 | FDB TOR-5 |
1068 | 1056 | FROMR FDB *+2 |
1069 | 1057 | LDX RP |
1070 | - LDA A 2,X | |
1071 | - LDA B 3,X | |
1058 | + LDD 2,X | |
1072 | 1059 | INX |
1073 | 1060 | INX |
1074 | 1061 | STX RP |
@@ -1078,11 +1065,7 @@ FROMR FDB *+2 | ||
1078 | 1065 | FCB $81 R |
1079 | 1066 | FCB $D2 |
1080 | 1067 | FDB FROMR-5 |
1081 | -R FDB *+2 | |
1082 | - LDX RP | |
1083 | - INX | |
1084 | - INX | |
1085 | - JMP GETX | |
1068 | +R FDB I+2 | |
1086 | 1069 | * |
1087 | 1070 | * ######>> screen 28 << |
1088 | 1071 | * ======>> 31 << |
@@ -1092,12 +1075,9 @@ R FDB *+2 | ||
1092 | 1075 | FDB R-4 |
1093 | 1076 | ZEQU FDB *+2 |
1094 | 1077 | TSX |
1095 | - CLR A | |
1096 | - CLR B | |
1097 | - LDX 0,X | |
1098 | - BNE ZEQU2 | |
1099 | - INC B | |
1100 | -ZEQU2 TSX | |
1078 | + LDD 0,X | |
1079 | + BNE ZLESSF Steal code. | |
1080 | +ZEQUT LDD #1 Make it stealable. | |
1101 | 1081 | JMP STABX |
1102 | 1082 | * |
1103 | 1083 | * ======>> 32 << |
@@ -1107,13 +1087,10 @@ ZEQU2 TSX | ||
1107 | 1087 | FDB ZEQU-5 |
1108 | 1088 | ZLESS FDB *+2 |
1109 | 1089 | TSX |
1110 | - LDA A #$80 check the sign bit | |
1111 | - AND A 0,X | |
1112 | - BEQ ZLESS2 | |
1113 | - CLR A if neg. | |
1114 | - LDA B #1 | |
1115 | - JMP STABX | |
1116 | -ZLESS2 CLR B | |
1090 | + LDD 0,X | |
1091 | + BMI ZEQUT | |
1092 | +ZLESSF CLR A | |
1093 | + CLR B | |
1117 | 1094 | JMP STABX |
1118 | 1095 | * |
1119 | 1096 | * ######>> screen 29 << |
@@ -1122,11 +1099,10 @@ ZLESS2 CLR B | ||
1122 | 1099 | FCB $AB |
1123 | 1100 | FDB ZLESS-5 |
1124 | 1101 | PLUS FDB *+2 |
1125 | - PUL A | |
1102 | + PUL A commutative | |
1126 | 1103 | PUL B |
1127 | 1104 | TSX |
1128 | - ADD B 1,X | |
1129 | - ADC A 0,X | |
1105 | + ADDD 0,X | |
1130 | 1106 | JMP STABX |
1131 | 1107 | * |
1132 | 1108 | * ======>> 34 << |
@@ -1136,14 +1112,13 @@ PLUS FDB *+2 | ||
1136 | 1112 | FDB PLUS-4 |
1137 | 1113 | DPLUS FDB *+2 |
1138 | 1114 | TSX |
1139 | - CLC | |
1140 | - LDA B #4 | |
1141 | -DPLUS2 LDA A 3,X | |
1142 | - ADC A 7,X | |
1143 | - STA A 7,X | |
1144 | - DEX | |
1145 | - DEC B | |
1146 | - BNE DPLUS2 | |
1115 | + LDD 6,X | |
1116 | + ADDD 2,X | |
1117 | + STD 6,X | |
1118 | + LDD 4,X | |
1119 | + ADC B 1,X | |
1120 | + ADC A 0,X | |
1121 | + STD 4,X | |
1147 | 1122 | INS |
1148 | 1123 | INS |
1149 | 1124 | INS |
@@ -1157,12 +1132,10 @@ DPLUS2 LDA A 3,X | ||
1157 | 1132 | FDB DPLUS-5 |
1158 | 1133 | MINUS FDB *+2 |
1159 | 1134 | TSX |
1160 | - NEG 1,X | |
1161 | - BCC MINUS2 | |
1162 | - NEG 0,X | |
1163 | - BRA MINUS3 | |
1164 | -MINUS2 COM 0,X | |
1165 | -MINUS3 JMP NEXT | |
1135 | + CLR B | |
1136 | + CLR A | |
1137 | + SUB D 0,X | |
1138 | + JMP STABX | |
1166 | 1139 | * |
1167 | 1140 | * ======>> 36 << |
1168 | 1141 | FCB $86 |
@@ -1171,17 +1144,14 @@ MINUS3 JMP NEXT | ||
1171 | 1144 | FDB MINUS-8 |
1172 | 1145 | DMINUS FDB *+2 |
1173 | 1146 | TSX |
1174 | - COM 0,X | |
1175 | - COM 1,X | |
1176 | - COM 2,X | |
1177 | - NEG 3,X | |
1178 | - BNE DMINX | |
1179 | - INC 2,X | |
1180 | - BNE DMINX | |
1181 | - INC 1,X | |
1182 | - BNE DMINX | |
1183 | - INC 0,X | |
1184 | -DMINX JMP NEXT | |
1147 | + CLR B | |
1148 | + CLR A | |
1149 | + SUB D 2,X | |
1150 | + STD 2,X | |
1151 | + LDD #0 | |
1152 | + SBC B 1,X | |
1153 | + SBC A 0,X | |
1154 | + JMP STABX | |
1185 | 1155 | * |
1186 | 1156 | * ######>> screen 30 << |
1187 | 1157 | * ======>> 37 << |
@@ -1191,8 +1161,7 @@ DMINX JMP NEXT | ||
1191 | 1161 | FDB DMINUS-9 |
1192 | 1162 | OVER FDB *+2 |
1193 | 1163 | TSX |
1194 | - LDA A 2,X | |
1195 | - LDA B 3,X | |
1164 | + LDD 2,X | |
1196 | 1165 | JMP PUSHBA |
1197 | 1166 | * |
1198 | 1167 | * ======>> 38 << |
@@ -1201,8 +1170,7 @@ OVER FDB *+2 | ||
1201 | 1170 | FCB $D0 |
1202 | 1171 | FDB OVER-7 |
1203 | 1172 | DROP FDB *+2 |
1204 | - INS | |
1205 | - INS | |
1173 | + PULX | |
1206 | 1174 | JMP NEXT |
1207 | 1175 | * |
1208 | 1176 | * ======>> 39 << |
@@ -1211,17 +1179,30 @@ DROP FDB *+2 | ||
1211 | 1179 | FCB $D0 |
1212 | 1180 | FDB DROP-7 |
1213 | 1181 | SWAP FDB *+2 |
1214 | - PUL A | |
1215 | - PUL B | |
1216 | - TSX | |
1217 | - LDX 0,X | |
1218 | - INS | |
1219 | - INS | |
1220 | - PSH B | |
1221 | - PSH A | |
1222 | - STX N | |
1223 | - LDX #N | |
1224 | - JMP GETX | |
1182 | + PULX | |
1183 | + PULA | |
1184 | + PULB | |
1185 | + PSHX | |
1186 | + PSHB | |
1187 | + PSHA | |
1188 | + JMP NEXT | |
1189 | +* TSX | |
1190 | +* LDD 2,X | |
1191 | +* STD N | |
1192 | +* LDD 0,X | |
1193 | +* STD 2,X | |
1194 | +* LDD N | |
1195 | +* JMP STABX | |
1196 | +* | |
1197 | +* LDA A 0,X | |
1198 | +* LDA B 2,X | |
1199 | +* STA B 0,X | |
1200 | +* STA A 2,X | |
1201 | +* LDA A 1,X | |
1202 | +* LDA B 3,X | |
1203 | +* STA B 1,X | |
1204 | +* STA A 3,X | |
1205 | +* JMP NEXT | |
1225 | 1206 | * |
1226 | 1207 | * ======>> 40 << |
1227 | 1208 | FCB $83 |
@@ -1229,11 +1210,13 @@ SWAP FDB *+2 | ||
1229 | 1210 | FCB $D0 |
1230 | 1211 | FDB SWAP-7 |
1231 | 1212 | DUP FDB *+2 |
1232 | - PUL A | |
1233 | - PUL B | |
1234 | - PSH B | |
1235 | - PSH A | |
1236 | - JMP PUSHBA | |
1213 | + PULX | |
1214 | + PSHX | |
1215 | + PSHX | |
1216 | + JMP NEXT | |
1217 | +* TSX | |
1218 | +* LDD 0,X | |
1219 | +* JMP PUSHBA | |
1237 | 1220 | * |
1238 | 1221 | * ######>> screen 31 << |
1239 | 1222 | * ======>> 41 << |
@@ -1242,16 +1225,11 @@ DUP FDB *+2 | ||
1242 | 1225 | FCB $A1 |
1243 | 1226 | FDB DUP-6 |
1244 | 1227 | PSTORE FDB *+2 |
1245 | - TSX | |
1246 | - LDX 0,X | |
1247 | - INS | |
1248 | - INS | |
1228 | + PULX | |
1249 | 1229 | PUL A get stack data |
1250 | 1230 | PUL B |
1251 | - ADD B 1,X add & store low byte | |
1252 | - STA B 1,X | |
1253 | - ADC A 0,X add & store hi byte | |
1254 | - STA A 0,X | |
1231 | + ADDD 0,X | |
1232 | + STD 0,X | |
1255 | 1233 | JMP NEXT |
1256 | 1234 | * |
1257 | 1235 | * ======>> 42 << |
@@ -1268,10 +1246,7 @@ TOGGLE FDB DOCOL,OVER,CAT,XOR,SWAP,CSTORE | ||
1268 | 1246 | FCB $C0 |
1269 | 1247 | FDB TOGGLE-9 |
1270 | 1248 | AT FDB *+2 |
1271 | - TSX | |
1272 | - LDX 0,X get address | |
1273 | - INS | |
1274 | - INS | |
1249 | + PULX | |
1275 | 1250 | JMP GETX |
1276 | 1251 | * |
1277 | 1252 | * ======>> 44 << |
@@ -1280,12 +1255,9 @@ AT FDB *+2 | ||
1280 | 1255 | FCB $C0 |
1281 | 1256 | FDB AT-4 |
1282 | 1257 | CAT FDB *+2 |
1283 | - TSX | |
1284 | - LDX 0,X | |
1258 | + PULX | |
1285 | 1259 | CLR A |
1286 | 1260 | LDA B 0,X |
1287 | - INS | |
1288 | - INS | |
1289 | 1261 | JMP PUSHBA |
1290 | 1262 | * |
1291 | 1263 | * ======>> 45 << |
@@ -1293,10 +1265,7 @@ CAT FDB *+2 | ||
1293 | 1265 | FCB $A1 |
1294 | 1266 | FDB CAT-5 |
1295 | 1267 | STORE FDB *+2 |
1296 | - TSX | |
1297 | - LDX 0,X get address | |
1298 | - INS | |
1299 | - INS | |
1268 | + PULX get address | |
1300 | 1269 | JMP PULABX |
1301 | 1270 | * |
1302 | 1271 | * ======>> 46 << |
@@ -1305,6 +1274,7 @@ STORE FDB *+2 | ||
1305 | 1274 | FCB $A1 |
1306 | 1275 | FDB STORE-4 |
1307 | 1276 | CSTORE FDB *+2 |
1277 | + | |
1308 | 1278 | TSX |
1309 | 1279 | LDX 0,X get address |
1310 | 1280 | INS |
@@ -1313,6 +1283,7 @@ CSTORE FDB *+2 | ||
1313 | 1283 | PUL B |
1314 | 1284 | STA B 0,X |
1315 | 1285 | JMP NEXT |
1286 | +* | |
1316 | 1287 | PAGE |
1317 | 1288 | * |
1318 | 1289 | * ######>> screen 33 << |
@@ -2619,11 +2590,10 @@ STOD FDB DOCOL,DUP,ZLESS,MINUS | ||
2619 | 2590 | FCB $81 ; * |
2620 | 2591 | FCB $AA |
2621 | 2592 | FDB STOD-7 |
2622 | -STAR FDB *+2 | |
2623 | - JSR USTARS | |
2624 | - INS | |
2625 | - INS | |
2626 | - JMP NEXT | |
2593 | +STAR FDB DOCOL | |
2594 | + FDB USTAR | |
2595 | + FDB DROP | |
2596 | + FDB SEMIS | |
2627 | 2597 | * |
2628 | 2598 | * ======>> 160 << |
2629 | 2599 | FCB $84 |
@@ -0,0 +1,47 @@ | ||
1 | +: STAR 42 EMIT ; | |
2 | +: STARS 0 DO STAR LOOP ; | |
3 | + | |
4 | +40 STARS | |
5 | + | |
6 | +: TEST 0 DO I . I EMIT CR LOOP ; | |
7 | +: TEST2 0 DO I . I EMIT CR 4 +LOOP ; | |
8 | +: TESTDOWN 256 DO I . I EMIT CR -4 +LOOP ; | |
9 | + | |
10 | +HEX | |
11 | +8000. 8000 U/ . . ( 1 0 ) | |
12 | +8000. 8001 U/ . . ( 0 -8000 ) | |
13 | + | |
14 | +SP@ . | |
15 | +SP! SP@ . | |
16 | + | |
17 | +4545.4545 3423.3423 D+ D. ( 79687968 ) | |
18 | +4545.5656 3423.DCDC D+ D. ( 79693332 ) | |
19 | +7FFF.FFFF 1. D+ D. ( -80000000 ) | |
20 | + | |
21 | +SP@ . | |
22 | + | |
23 | +8001 MINUS . | |
24 | +8000 MINUS . | |
25 | + | |
26 | +7FFF.FFFF DMINUS D. | |
27 | +8000.0001 DMINUS D. | |
28 | +8000.0000 DMINUS D. | |
29 | + | |
30 | +SP@ . | |
31 | + | |
32 | +45AA 10 OVER . . . | |
33 | + | |
34 | +SP@ . | |
35 | + | |
36 | +45AA 10 SWAP . . | |
37 | + | |
38 | +SP@ . | |
39 | + | |
40 | +1 VARIABLE ALPHA | |
41 | + | |
42 | +ALPHA 1+ F0 TOGGLE ALPHA @ . | |
43 | + | |
44 | + | |
45 | + | |
46 | + | |
47 | + |
@@ -20,6 +20,7 @@ | ||
20 | 20 | #include <stdlib.h> |
21 | 21 | #include <string.h> |
22 | 22 | |
23 | +#include "exorsim.h" /* JMR20201103 */ | |
23 | 24 | #include "unasm6800.h" |
24 | 25 | #include "utils.h" /* JMR20201103 */ |
25 | 26 |
@@ -266,7 +267,11 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
266 | 267 | sprintf(buf + strlen(buf), "%2.2X ", opcode = mem[pc++]); |
267 | 268 | |
268 | 269 | if (opcode & 0x80) { |
270 | +#ifdef SIM6801 | |
271 | + if ( ((opcode & 0x0F) < 0x0C) && ((opcode & 0x0F) != 0x03) ) { | |
272 | +#else | |
269 | 273 | if ((opcode & 0x0F) < 0x0C) { |
274 | +#endif /* def SIM6801 */ | |
270 | 275 | /* Get operand A */ |
271 | 276 | if (opcode & 0x40) { |
272 | 277 | sprintf(operand, "B"); |
@@ -316,10 +321,19 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
316 | 321 | } case 0x02: /* SBC N,Z,V,C (no H?) */ { |
317 | 322 | insn = "SBC"; |
318 | 323 | break; |
319 | - } case 0x03: /* ??? */ { | |
324 | + } | |
325 | +#ifdef SIM6801 | |
326 | + case 0x03: /* ACCMD should never get here at run time. */ { | |
327 | + insn = ""; | |
328 | + break; | |
329 | + } | |
330 | +#else | |
331 | + case 0x03: /* ??? */ { | |
320 | 332 | insn = "???"; |
321 | 333 | break; |
322 | - } case 0x04: /* AND N,Z,V=0 */ { | |
334 | + } | |
335 | +#endif /* ndef SIM6801 */ | |
336 | + case 0x04: /* AND N,Z,V=0 */ { | |
323 | 337 | insn = "AND"; |
324 | 338 | break; |
325 | 339 | } case 0x05: /* BIT N,Z,V=0*/ { |
@@ -375,7 +389,13 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
375 | 389 | } |
376 | 390 | } |
377 | 391 | switch (opcode) { |
378 | - case 0x8C: case 0x9C: case 0xAC: case 0xBC: /* CPX N,Z,V */ { | |
392 | +#ifdef SIM6801 | |
393 | + case 0x83: case 0x93: case 0xA3: case 0xB3: /* SUBD N,Z,V,C (6801) */ { | |
394 | + insn = "SUBD"; | |
395 | + break; | |
396 | + } | |
397 | +#endif /* def SIM6801 */ | |
398 | + case 0x8C: case 0x9C: case 0xAC: case 0xBC: /* CPX N,Z,V */ { | |
379 | 399 | insn = "CPX"; |
380 | 400 | break; |
381 | 401 | } case 0x8D: /* BSR REL */ { |
@@ -390,12 +410,29 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
390 | 410 | } case 0x8F: case 0x9F: case 0xAF: case 0xBF: /* STS N,Z,V */ { |
391 | 411 | insn = "STS"; |
392 | 412 | break; |
393 | - } case 0xAD: case 0xBD: /* JSR */ { | |
413 | + } | |
414 | +#ifdef SIM6801 | |
415 | + case 0x9D: /* (6801) */ | |
416 | +#endif /* def SIM6801 */ | |
417 | + case 0xAD: case 0xBD: /* JSR */ { | |
394 | 418 | branch_target = (mem[pc - 2] << 8) + mem[pc - 1]; |
395 | 419 | is_jsr = 1; |
396 | 420 | insn = "JSR"; |
397 | 421 | break; |
398 | - } case 0xCE: case 0xDE: case 0xEE: case 0xFE: /* LDX N,Z,V */ { | |
422 | + } | |
423 | +#ifdef SIM6801 | |
424 | + case 0xC3: case 0xD3: case 0xE3: case 0xF3: /* ADDD N,Z,V,C (6801) */ { | |
425 | + insn = "ADDD"; | |
426 | + break; | |
427 | + } case 0xCC: case 0xDC: case 0xEC: case 0xFC: /* LDD N,Z,V=0 (6801) */ { | |
428 | + insn = "LDD"; | |
429 | + break; | |
430 | + } case 0xCD: case 0xDD: case 0xED: case 0xFD: /* STD N,Z,V=0 (6801) */ { | |
431 | + insn = "STD"; | |
432 | + break; | |
433 | + } | |
434 | +#endif /* def SIM6801 */ | |
435 | + case 0xCE: case 0xDE: case 0xEE: case 0xFE: /* LDX N,Z,V */ { | |
399 | 436 | insn = "LDX"; |
400 | 437 | break; |
401 | 438 | } case 0xCF: case 0xDF: case 0xEF: case 0xFF: /* STX N,Z,V */ { |
@@ -483,7 +520,17 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
483 | 520 | case 0x01: /* NOP */ { /* Do nothing */ |
484 | 521 | insn = "NOP"; |
485 | 522 | break; |
486 | - } case 0x06: /* TAP (all flags) */ { | |
523 | + } | |
524 | +#ifdef SIM6801 | |
525 | + case 0x04: /* LSRD N=0,Z,V,C (6801) */ { | |
526 | + insn = "LSRD"; | |
527 | + break; | |
528 | + } case 0x05: /* LSLD N,Z,V,C (6801) */ { | |
529 | + insn = "LSLD"; | |
530 | + break; | |
531 | + } | |
532 | +#endif /* def SIM6801 */ | |
533 | + case 0x06: /* TAP (all flags) */ { | |
487 | 534 | insn = "TAP"; |
488 | 535 | break; |
489 | 536 | } case 0x07: /* TPA */ { |
@@ -538,7 +585,18 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
538 | 585 | sprintf(operand + strlen(operand), " $%4.4X", branch_target); |
539 | 586 | insn = "BRA"; |
540 | 587 | break; |
541 | - } case 0x22: /* BHI */ { | |
588 | + } | |
589 | +#ifdef SIM6801 | |
590 | + case 0x21: /* BRN (6801) */ { | |
591 | + offset = mem[pc++]; | |
592 | + sprintf(buf + strlen(buf), "%2.2X ", mem[pc - 1]); | |
593 | + branch_target = pc + offset; | |
594 | + sprintf(operand + strlen(operand), " $%4.4X", branch_target); | |
595 | + insn = "BRN"; | |
596 | + break; | |
597 | + } | |
598 | +#endif /* def SIM6801 */ | |
599 | + case 0x22: /* BHI */ { | |
542 | 600 | offset = mem[pc++]; |
543 | 601 | sprintf(buf + strlen(buf), "%2.2X ", mem[pc - 1]); |
544 | 602 | branch_target = pc + offset; |
@@ -660,13 +718,37 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
660 | 718 | } case 0x37: /* PSHB */ { |
661 | 719 | insn = "PSHB"; |
662 | 720 | break; |
663 | - } case 0x39: /* RTS */ { | |
721 | + } | |
722 | +#ifdef SIM6801 | |
723 | + case 0x38: /* PULX (6801) */ { | |
724 | + insn = "PULX"; | |
725 | + break; | |
726 | + } | |
727 | +#endif /* def SIM6801 */ | |
728 | + case 0x39: /* RTS */ { | |
664 | 729 | insn = "RTS"; |
665 | 730 | break; |
666 | - } case 0x3B: /* RTI */ { | |
731 | + } | |
732 | +#ifdef SIM6801 | |
733 | + case 0x3A: /* ABX (6801) */ { | |
734 | + insn = "ABX"; | |
735 | + break; | |
736 | + } | |
737 | +#endif /* def SIM6801 */ | |
738 | + case 0x3B: /* RTI */ { | |
667 | 739 | insn = "RTI"; |
668 | 740 | break; |
669 | - } case 0x3E: /* WAI */ { | |
741 | + } | |
742 | +#ifdef SIM6801 | |
743 | + case 0x3C: /* PSHX (6801) */ { | |
744 | + insn = "PSHX"; | |
745 | + break; | |
746 | + } case 0x3D: /* MUL C=accb bit 7 (6801) */ { | |
747 | + insn = "MUL"; | |
748 | + break; | |
749 | + } | |
750 | +#endif /* def SIM6801 */ | |
751 | + case 0x3E: /* WAI */ { | |
670 | 752 | insn = "WAI"; |
671 | 753 | break; |
672 | 754 | } case 0x3F: /* SWI */ { |