Debian Codegraph @

pep.h

raw symbols SCIP
1 // File: pep.h
2 /*
3 Pep8-1 is a virtual machine for writing machine language and assembly
4 language programs.
5
6 Copyright (C) 2009 J. Stanley Warford, Pepperdine University
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef PEP_H
23 #define PEP_H
24
25 #include <QMap>
26 #include <QSet>
27 #include <QString>
28 #include <QStringList>
29 #include <QVector>
30 #include <QColor>
31
32 #include "enu.h"
33
34 class Pep
35 {
36 public:
37 // Fonts:
38 static const QString codeFont;
39 static const int codeFontSize;
40 static const int ioFontSize;
41 static const QString labelFont;
42 static const int labelFontSize;
43
44 // Default redefine mnemonics
45 static const QString defaultUnaryMnemonic0;
46 static const QString defaultUnaryMnemonic1;
47 static const QString defaultUnaryMnemonic2;
48 static const QString defaultUnaryMnemonic3;
49 static const QString defaultNonUnaryMnemonic0;
50 static const bool defaultMnemon0i;
51 static const bool defaultMnemon0d;
52 static const bool defaultMnemon0n;
53 static const bool defaultMnemon0s;
54 static const bool defaultMnemon0sf;
55 static const bool defaultMnemon0x;
56 static const bool defaultMnemon0sx;
57 static const bool defaultMnemon0sxf;
58 static const QString defaultNonUnaryMnemonic1;
59 static const bool defaultMnemon1i;
60 static const bool defaultMnemon1d;
61 static const bool defaultMnemon1n;
62 static const bool defaultMnemon1s;
63 static const bool defaultMnemon1sf;
64 static const bool defaultMnemon1x;
65 static const bool defaultMnemon1sx;
66 static const bool defaultMnemon1sxf;
67 static const QString defaultNonUnaryMnemonic2;
68 static const bool defaultMnemon2i;
69 static const bool defaultMnemon2d;
70 static const bool defaultMnemon2n;
71 static const bool defaultMnemon2s;
72 static const bool defaultMnemon2sf;
73 static const bool defaultMnemon2x;
74 static const bool defaultMnemon2sx;
75 static const bool defaultMnemon2sxf;
76 static const QString defaultNonUnaryMnemonic3;
77 static const bool defaultMnemon3i;
78 static const bool defaultMnemon3d;
79 static const bool defaultMnemon3n;
80 static const bool defaultMnemon3s;
81 static const bool defaultMnemon3sf;
82 static const bool defaultMnemon3x;
83 static const bool defaultMnemon3sx;
84 static const bool defaultMnemon3sxf;
85
86 // Functions for computing instruction specifiers
87 static int aaaAddressField(Enu::EAddrMode addressMode);
88 static int aAddressField(Enu::EAddrMode addressMode);
89 static QString intToAddrMode(Enu::EAddrMode addressMode);
90 static QString commaSpaceToAddrMode(Enu::EAddrMode addressMode);
91
92 // Function to read text from a resource file
93 static QString resToString(QString fileName);
94 // Function for getting the system we're running on
95 static QString getSystem();
96
97 // Maps between mnemonic enums and strings
98 static QMap<Enu::EMnemonic, QString> enumToMnemonMap;
99 static QMap<QString, Enu::EMnemonic> mnemonToEnumMap;
100 static void initEnumMnemonMaps();
101
102 // Maps to characterize each instruction
103 static QMap<Enu::EMnemonic, int> opCodeMap;
104 static QMap<Enu::EMnemonic, bool> isUnaryMap;
105 static QMap<Enu::EMnemonic, bool> addrModeRequiredMap;
106 static QMap<Enu::EMnemonic, bool> isTrapMap;
107 static void initMnemonicMaps();
108
109 // Map to specify legal addressing modes for each instruction
110 static QMap<Enu::EMnemonic, int> addrModesMap;
111 static void initAddrModesMap();
112
113 // The symbol table
114 static QMap<QString, int> symbolTable;
115 static QMap<QString, bool> adjustSymbolValueForBurn;
116
117 // The trace tag tables
118 static QMap<QString, Enu::ESymbolFormat> symbolFormat;
119 static QMap<QString, int> symbolFormatMultiplier;
120
121 // This map is for global structs. The key is the symbol defined on the .BLOCK line
122 // and QStringList contains the list of symbols from the symbol tags in the .BLOCK comment.
123 static QMap<QString, QStringList> globalStructSymbols;
124
125 // This map is used to map the program counter to the stringList of tags on the corresponding line
126 // For example, line corresponds to 0x12, and has the comment ; Allocate #next #data
127 // The stringlist would contain next and data
128 static QMap<int, QStringList> symbolTraceList;
129
130 static QStringList blockSymbols;
131 static QStringList equateSymbols;
132
133 // Map from instruction memory address to assembler listing line
134 // These pointers are set to the addresses of the program or OS maps
135 // depending on whether the program or OS is being assembled
136 static QMap<int, int> *memAddrssToAssemblerListing;
137 static QMap<int, Qt::CheckState> *listingRowChecked;
138
139 static QMap<int, int> memAddrssToAssemblerListingProg;
140 static QMap<int, Qt::CheckState> listingRowCheckedProg;
141
142 static QMap<int, int> memAddrssToAssemblerListingOS;
143 static QMap<int, Qt::CheckState> listingRowCheckedOS;
144
145 // Decoder tables
146 static QVector<Enu::EMnemonic> decodeMnemonic;
147 static QVector<Enu::EAddrMode> decodeAddrMode;
148 static void initDecoderTables();
149
150 // .BURN and the ROM state
151 static int byteCount;
152 static int burnCount;
153 static int dotBurnArgument;
154 static int romStartAddress;
155
156 // Memory trace state
157 static bool traceTagWarning;
158 };
159
160 #endif // PEP_H