| 1 | // File: asm.cppcxx . . $ `<file>/asm.cpp`/ |
| 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 | #include "asm.h"cxx . . $ `<file>/asm.h`/ |
| 22 | #include "argument.h"cxx . . $ `<file>/argument.h`/ |
| 23 | #include "code.h"cxx . . $ `<file>/code.h`/ |
| 24 | |
| 25 | // Regular expressions for lexical analysis |
| 26 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxAddrModecxx . . $ Asm#rxAddrMode.("^((,)(\\s*)(i|d|x|n|s(?![fx])|sx(?![f])|sf|sxf){1}){1}"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 27 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxCharConstcxx . . $ Asm#rxCharConst.("^((\')(?![\'])(([^\'\\\\]){1}|((\\\\)([\'|b|f|n|r|t|v|\"|\\\\]))|((\\\\)(([x|X])([0-9|A-F|a-f]{2}))))(\'))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 28 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxCommentcxx . . $ Asm#rxComment.("^((;{1})(.)*)"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 29 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxDecConstcxx . . $ Asm#rxDecConst.("^((([+|-]{0,1})([0-9]+))|^(([1-9])([0-9]*)))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 30 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxDotCommandcxx . . $ Asm#rxDotCommand.("^((.)(([A-Z|a-z]{1})(\\w)*))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 31 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxHexConstcxx . . $ Asm#rxHexConst.("^((0(?![x|X]))|((0)([x|X])([0-9|A-F|a-f])+)|((0)([0-9]+)))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 32 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxIdentifiercxx . . $ Asm#rxIdentifier.("^((([A-Z|a-z|_]{1})(\\w*))(:){0,1})"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 33 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxStringConstcxx . . $ Asm#rxStringConst.("^((\")((([^\"\\\\])|((\\\\)([\'|b|f|n|r|t|v|\"|\\\\]))|((\\\\)(([x|X])([0-9|A-F|a-f]{2}))))*)(\"))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 34 | |
| 35 | // Regular expressions for trace tag analysis |
| 36 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxFormatTagcxx . . $ Asm#rxFormatTag.("(#((1c)|(1d)|(1h)|(2d)|(2h))((\\d)+a)?(\\s|$))"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 37 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxSymbolTagcxx . . $ Asm#rxSymbolTag.("#([a-zA-Z][a-zA-Z0-9]{0,7})"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 38 | QRegExpcxx . . $ QRegExp# Asmcxx . . $ Asm#::rxArrayMultipliercxx . . $ Asm#rxArrayMultiplier.("((\\d)+)a"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 39 | |
| 40 | bool Asmcxx . . $ Asm#::getTokencxx . . $ Asm#getToken(108e64ee63107a0f).(QStringcxx . . $ QString# &sourceLine, ELexicalTokencxx . . $ Asm#ELexicalToken# &token, QStringcxx . . $ QString# &tokenString) |
| 41 | { |
| 42 | |
| 43 | |
| 44 | sourceLine =cxx . . $ QString#`operator=`(4f35bf974e7f8568). sourceLine.trimmedcxx . . $ QString#trimmed(dca2c5857e9adf82).(); |
| 45 | if (sourceLine.lengthcxx . . $ QString#length(455f465bc33b4cdf).() == 0) { |
| 46 | token = LT_EMPTYcxx . . $ Asm#LT_EMPTY.; |
| 47 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 48 | return true; |
| 49 | } |
| 50 | QCharcxx . . $ QChar# firstChar = sourceLine[cxx . . $ QString#`operator[]`(57436120916eb52c).0]; |
| 51 | rxAddrModecxx . . $ Asm#rxAddrMode..setCaseSensitivitycxx . . $ QRegExp#setCaseSensitivity(dbd87adfa24451df). (Qtcxx . . $ Qt/::CaseInsensitivecxx . . $ Qt/CaseInsensitive.); // Make rxAddrMode not case sensitive |
| 52 | if (firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). ','cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 53 | if (rxAddrModecxx . . $ Asm#rxAddrMode..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 54 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed addressing mode."; |
| 55 | return false; |
| 56 | } |
| 57 | token = LT_ADDRESSING_MODEcxx . . $ Asm#LT_ADDRESSING_MODE.; |
| 58 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxAddrModecxx . . $ Asm#rxAddrMode..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 59 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 60 | return true; |
| 61 | } |
| 62 | if (firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '\''cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 63 | if (rxCharConstcxx . . $ Asm#rxCharConst..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 64 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed character constant."; |
| 65 | return false; |
| 66 | } |
| 67 | token = LT_CHAR_CONSTANTcxx . . $ Asm#LT_CHAR_CONSTANT.; |
| 68 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxCharConstcxx . . $ Asm#rxCharConst..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 69 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 70 | return true; |
| 71 | } |
| 72 | if (firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). ';'cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 73 | if (rxCommentcxx . . $ Asm#rxComment..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 74 | // This error should not occur, as any characters are allowed in a comment. |
| 75 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed comment"; |
| 76 | return false; |
| 77 | } |
| 78 | token = LT_COMMENTcxx . . $ Asm#LT_COMMENT.; |
| 79 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxCommentcxx . . $ Asm#rxComment..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 80 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 81 | return true; |
| 82 | } |
| 83 | if (startsWithHexPrefixcxx . . $ Asm#startsWithHexPrefix(7dc6c9a0b6a7270f).(sourceLinecxx . . $ QString#QString(132dd6869045752b).)) { |
| 84 | if (rxHexConstcxx . . $ Asm#rxHexConst..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 85 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed hex constant."; |
| 86 | return false; |
| 87 | } |
| 88 | token = LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.; |
| 89 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxHexConstcxx . . $ Asm#rxHexConst..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 90 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 91 | return true; |
| 92 | } |
| 93 | if ((firstChar.isDigitcxx . . $ QChar#isDigit(3482b152b9333168).() || firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '+'cxx . . $ QChar#QChar(f349c77f591a7878). || firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '-'cxx . . $ QChar#QChar(f349c77f591a7878).)) { |
| 94 | if (rxDecConstcxx . . $ Asm#rxDecConst..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 95 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed decimal constant."; |
| 96 | return false; |
| 97 | } |
| 98 | token = LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.; |
| 99 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxDecConstcxx . . $ Asm#rxDecConst..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 100 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 101 | return true; |
| 102 | } |
| 103 | if (firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '.'cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 104 | if (rxDotCommandcxx . . $ Asm#rxDotCommand..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 105 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed dot command."; |
| 106 | return false; |
| 107 | } |
| 108 | token = LT_DOT_COMMANDcxx . . $ Asm#LT_DOT_COMMAND.; |
| 109 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxDotCommandcxx . . $ Asm#rxDotCommand..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 110 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 111 | return true; |
| 112 | } |
| 113 | if (firstChar.isLettercxx . . $ QChar#isLetter(3482b152b9333168).() || firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '_'cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 114 | if (rxIdentifiercxx . . $ Asm#rxIdentifier..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 115 | // This error should not occur, as one-character identifiers are valid. |
| 116 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed identifier."; |
| 117 | return false; |
| 118 | } |
| 119 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxIdentifiercxx . . $ Asm#rxIdentifier..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 120 | token = tokenString.endsWithcxx . . $ QString#endsWith(7cf081d1b6a1defd).(':'cxx . . $ QChar#QChar(f349c77f591a7878).) ? LT_SYMBOL_DEFcxx . . $ Asm#LT_SYMBOL_DEF. : LT_IDENTIFIERcxx . . $ Asm#LT_IDENTIFIER.; |
| 121 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 122 | return true; |
| 123 | } |
| 124 | if (firstChar ==cxx . . $ `operator==`(a468b2f18a3afe8). '\"'cxx . . $ QChar#QChar(f349c77f591a7878).) { |
| 125 | if (rxStringConstcxx . . $ Asm#rxStringConst..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(sourceLine) == -1) { |
| 126 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Malformed string constant."; |
| 127 | return false; |
| 128 | } |
| 129 | token = LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.; |
| 130 | tokenString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rxStringConstcxx . . $ Asm#rxStringConst..capturedTextscxx . . $ QRegExp#capturedTexts(669a05bc42dd57cc).()[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).0]; |
| 131 | sourceLine.removecxx . . $ QString#remove(6483560ce2afa901).(0, tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).()); |
| 132 | return true; |
| 133 | } |
| 134 | tokenString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Syntax error."; |
| 135 | return false; |
| 136 | } |
| 137 | |
| 138 | QListcxx . . $ QList#<QStringcxx . . $ QString#> Asmcxx . . $ Asm#::listOfReferencedSymbolscxx . . $ Asm#listOfReferencedSymbols.; |
| 139 | QListcxx . . $ QList#<int> Asmcxx . . $ Asm#::listOfReferencedSymbolLineNumscxx . . $ Asm#listOfReferencedSymbolLineNums.; |
| 140 | |
| 141 | |
| 142 | bool Asmcxx . . $ Asm#::startsWithHexPrefixcxx . . $ Asm#startsWithHexPrefix(7dc6c9a0b6a7270f).(QStringcxx . . $ QString# str) |
| 143 | { |
| 144 | if (str.lengthcxx . . $ QString#length(455f465bc33b4cdf).() < 2) return false; |
| 145 | if (str[cxx . . $ QString#`operator[]`(57436120916eb52c).0] !=cxx . . $ `operator!=`(a468b2f18a3afe8). '0'cxx . . $ QChar#QChar(f349c77f591a7878).) return false; |
| 146 | if (str[cxx . . $ QString#`operator[]`(57436120916eb52c).1] ==cxx . . $ `operator==`(a468b2f18a3afe8). 'x'cxx . . $ QChar#QChar(f349c77f591a7878). || str[cxx . . $ QString#`operator[]`(57436120916eb52c).1] ==cxx . . $ `operator==`(a468b2f18a3afe8). 'X'cxx . . $ QChar#QChar(f349c77f591a7878).) return true; |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | Enucxx . . $ Enu/::EAddrModecxx . . $ Enu/EAddrMode# Asmcxx . . $ Asm#::stringToAddrModecxx . . $ Asm#stringToAddrMode(f9b7f5c0e4b95d6e).(QStringcxx . . $ QString# str) |
| 151 | { |
| 152 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the comma. |
| 153 | str =cxx . . $ QString#`operator=`(4f35bf974e7f8568). str.trimmedcxx . . $ QString#trimmed(dca2c5857e9adf82).().toUppercxx . . $ QString#toUpper(30b3b70527b1c61a).(); |
| 154 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "I") return Enucxx . . $ Enu/::Icxx . . $ Enu/I.; |
| 155 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "D") return Enucxx . . $ Enu/::Dcxx . . $ Enu/D.; |
| 156 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "N") return Enucxx . . $ Enu/::Ncxx . . $ Enu/N.; |
| 157 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "S") return Enucxx . . $ Enu/::Scxx . . $ Enu/S.; |
| 158 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "SF") return Enucxx . . $ Enu/::SFcxx . . $ Enu/SF.; |
| 159 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "X") return Enucxx . . $ Enu/::Xcxx . . $ Enu/X.; |
| 160 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "SX") return Enucxx . . $ Enu/::SXcxx . . $ Enu/SX.; |
| 161 | if (str ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "SXF") return Enucxx . . $ Enu/::SXFcxx . . $ Enu/SXF.; |
| 162 | return Enucxx . . $ Enu/::NONEcxx . . $ Enu/NONE.; |
| 163 | } |
| 164 | |
| 165 | int Asmcxx . . $ Asm#::charStringToIntcxx . . $ Asm#charStringToInt(87a9b7c6fe1ccdba).(QStringcxx . . $ QString# str) |
| 166 | { |
| 167 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the leftmost single quote. |
| 168 | str.chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // Remove the rightmost single quote. |
| 169 | int value; |
| 170 | Asmcxx . . $ Asm#::unquotedStringToIntcxx . . $ Asm#unquotedStringToInt(ed22d69ba8f9ce68).(str, value); |
| 171 | return value; |
| 172 | } |
| 173 | |
| 174 | int Asmcxx . . $ Asm#::string2ArgumentToIntcxx . . $ Asm#string2ArgumentToInt(87a9b7c6fe1ccdba).(QStringcxx . . $ QString# str) { |
| 175 | int valueA, valueB; |
| 176 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the leftmost double quote. |
| 177 | str.chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // Remove the rightmost double quote. |
| 178 | Asmcxx . . $ Asm#::unquotedStringToIntcxx . . $ Asm#unquotedStringToInt(ed22d69ba8f9ce68).(str, valueA); |
| 179 | if (str.lengthcxx . . $ QString#length(455f465bc33b4cdf).() == 0) { |
| 180 | return valueA; |
| 181 | } |
| 182 | else { |
| 183 | Asmcxx . . $ Asm#::unquotedStringToIntcxx . . $ Asm#unquotedStringToInt(ed22d69ba8f9ce68).(str, valueB); |
| 184 | valueA = 256 * valueA + valueB; |
| 185 | if (valueA < 0) { |
| 186 | valueA += 65536; // Stored as two-byte unsigned. |
| 187 | } |
| 188 | return valueA; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | void Asmcxx . . $ Asm#::unquotedStringToIntcxx . . $ Asm#unquotedStringToInt(ed22d69ba8f9ce68).(QStringcxx . . $ QString# &str, int &value) |
| 193 | { |
| 194 | QStringcxx . . $ QString# scxx . . $ QString#QString(ced63f7c635d850d).; |
| 195 | if (str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\x"cxx . . $ QString#QString(85c52e162fed56f9).) || str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\X"cxx . . $ QString#QString(85c52e162fed56f9).)) { |
| 196 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove the leading \x or \X |
| 197 | s =cxx . . $ QString#`operator=`(4f35bf974e7f8568). str.leftcxx . . $ QString#left(3f3c3d0e9c0eb37f).(2); |
| 198 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Get the two-char hex number |
| 199 | bool ok; |
| 200 | value = s.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 201 | } |
| 202 | else if (str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\"cxx . . $ QString#QString(85c52e162fed56f9).)) { |
| 203 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the leading bash |
| 204 | s =cxx . . $ QString#`operator=`(4f35bf974e7f8568). str.leftcxx . . $ QString#left(3f3c3d0e9c0eb37f).(1); |
| 205 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0,1); |
| 206 | if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "b") { // backspace |
| 207 | value = 8; |
| 208 | } |
| 209 | else if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "f") { // form feed |
| 210 | value = 12; |
| 211 | } |
| 212 | else if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "n") { // line feed (new line) |
| 213 | value = 10; |
| 214 | } |
| 215 | else if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "r") { // carriage return |
| 216 | value = 13; |
| 217 | } |
| 218 | else if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "t") { // horizontal tab |
| 219 | value = 9; |
| 220 | } |
| 221 | else if (s ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "v") { // vertical tab |
| 222 | value = 11; |
| 223 | } |
| 224 | else { |
| 225 | value = QCharcxx . . $ QChar#(s[cxx . . $ QString#`operator[]`(57436120916eb52c).0]).toLatin1cxx . . $ QChar#toLatin1(a33b425be6aff8f0).(); |
| 226 | } |
| 227 | } |
| 228 | else { |
| 229 | s =cxx . . $ QString#`operator=`(4f35bf974e7f8568). str.leftcxx . . $ QString#left(3f3c3d0e9c0eb37f).(1); |
| 230 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); |
| 231 | value = QCharcxx . . $ QChar#(s[cxx . . $ QString#`operator[]`(57436120916eb52c).0]).toLatin1cxx . . $ QChar#toLatin1(a33b425be6aff8f0).(); |
| 232 | } |
| 233 | value += value < 0 ? 256 : 0; |
| 234 | } |
| 235 | |
| 236 | int Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(QStringcxx . . $ QString# str) |
| 237 | { |
| 238 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the leftmost double quote. |
| 239 | str.chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // Remove the rightmost double quote. |
| 240 | int length = 0; |
| 241 | while (str.lengthcxx . . $ QString#length(455f465bc33b4cdf).() > 0) { |
| 242 | if (str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\x"cxx . . $ QString#QString(85c52e162fed56f9).) || str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\X"cxx . . $ QString#QString(85c52e162fed56f9).)) { |
| 243 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 4); // Remove the \xFF |
| 244 | } |
| 245 | else if (str.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("\\"cxx . . $ QString#QString(85c52e162fed56f9).)) { |
| 246 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove the quoted character |
| 247 | } |
| 248 | else { |
| 249 | str.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the single character |
| 250 | } |
| 251 | length++; |
| 252 | } |
| 253 | return length; |
| 254 | } |
| 255 | |
| 256 | Enucxx . . $ Enu/::ESymbolFormatcxx . . $ Enu/ESymbolFormat# Asmcxx . . $ Asm#::formatTagTypecxx . . $ Asm#formatTagType(719bfaa963bc79d3).(QStringcxx . . $ QString# formatTag) { |
| 257 | if (formatTag.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("#1c"cxx . . $ QString#QString(85c52e162fed56f9).)) return Enucxx . . $ Enu/::F_1Ccxx . . $ Enu/F_1C.; |
| 258 | if (formatTag.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("#1d"cxx . . $ QString#QString(85c52e162fed56f9).)) return Enucxx . . $ Enu/::F_1Dcxx . . $ Enu/F_1D.; |
| 259 | if (formatTag.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("#2d"cxx . . $ QString#QString(85c52e162fed56f9).)) return Enucxx . . $ Enu/::F_2Dcxx . . $ Enu/F_2D.; |
| 260 | if (formatTag.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("#1h"cxx . . $ QString#QString(85c52e162fed56f9).)) return Enucxx . . $ Enu/::F_1Hcxx . . $ Enu/F_1H.; |
| 261 | if (formatTag.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("#2h"cxx . . $ QString#QString(85c52e162fed56f9).)) return Enucxx . . $ Enu/::F_2Hcxx . . $ Enu/F_2H.; |
| 262 | return Enucxx . . $ Enu/::F_NONEcxx . . $ Enu/F_NONE.; // Should not occur |
| 263 | } |
| 264 | |
| 265 | int Asmcxx . . $ Asm#::tagNumBytescxx . . $ Asm#tagNumBytes(10342dda07a560ad).(Enucxx . . $ Enu/::ESymbolFormatcxx . . $ Enu/ESymbolFormat# symbolFormat) { |
| 266 | switch (symbolFormat) { |
| 267 | case Enucxx . . $ Enu/::F_1Ccxx . . $ Enu/F_1C.: return 1; |
| 268 | case Enucxx . . $ Enu/::F_1Dcxx . . $ Enu/F_1D.: return 1; |
| 269 | case Enucxx . . $ Enu/::F_2Dcxx . . $ Enu/F_2D.: return 2; |
| 270 | case Enucxx . . $ Enu/::F_1Hcxx . . $ Enu/F_1H.: return 1; |
| 271 | case Enucxx . . $ Enu/::F_2Hcxx . . $ Enu/F_2H.: return 2; |
| 272 | case Enucxx . . $ Enu/::F_NONEcxx . . $ Enu/F_NONE.: return 0; |
| 273 | default: return -1; // Should not occur. |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | int Asmcxx . . $ Asm#::formatMultipliercxx . . $ Asm#formatMultiplier(87a9b7c6fe1ccdba).(QStringcxx . . $ QString# formatTag) { |
| 278 | int pos = Asmcxx . . $ Asm#::rxArrayMultipliercxx . . $ Asm#rxArrayMultiplier..indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(formatTag); |
| 279 | if (pos > -1) { |
| 280 | QStringcxx . . $ QString# multiplierTag = Asmcxx . . $ Asm#::rxArrayMultipliercxx . . $ Asm#rxArrayMultiplier..capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(0); |
| 281 | multiplierTag.chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // Remove the last character 'a' from the array tag. |
| 282 | return multiplierTag.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 283 | } |
| 284 | else { |
| 285 | return 1; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | bool Asmcxx . . $ Asm#::processSourceLinecxx . . $ Asm#processSourceLine(3c7c08c96e7ded6c).(QStringcxx . . $ QString# sourceLine, int lineNum, Codecxx . . $ Code# *&code, QStringcxx . . $ QString# &errorString, bool &dotEndDetected) |
| 290 | { |
| 291 | Asmcxx . . $ Asm#::ELexicalTokencxx . . $ Asm#ELexicalToken# token; // Passed to getToken. |
| 292 | QStringcxx . . $ QString# tokenStringcxx . . $ QString#QString(ced63f7c635d850d).; // Passed to getToken. |
| 293 | QStringcxx . . $ QString# localSymbolDef = ""cxx . . $ QString#QString(85c52e162fed56f9).; // Saves symbol definition for processing in the following state. |
| 294 | Enucxx . . $ Enu/::EMnemoniccxx . . $ Enu/EMnemonic# localEnumMnemonic; // Key to Pep:: table lookups. |
| 295 | |
| 296 | // The concrete code objects asssigned to code. |
| 297 | UnaryInstructioncxx . . $ UnaryInstruction# *unaryInstruction = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 298 | NonUnaryInstructioncxx . . $ NonUnaryInstruction# *nonUnaryInstruction = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 299 | DotAddrsscxx . . $ DotAddrss# *dotAddrss = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 300 | DotAsciicxx . . $ DotAscii# *dotAscii = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 301 | DotBlockcxx . . $ DotBlock# *dotBlock = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 302 | DotBurncxx . . $ DotBurn# *dotBurn = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 303 | DotBytecxx . . $ DotByte# *dotByte = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 304 | DotEndcxx . . $ DotEnd# *dotEnd = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 305 | DotEquatecxx . . $ DotEquate# *dotEquate = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 306 | DotWordcxx . . $ DotWord# *dotWord = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 307 | CommentOnlycxx . . $ CommentOnly# *commentOnly = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 308 | BlankLinecxx . . $ BlankLine# *blankLine = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 309 | |
| 310 | dotEndDetected = false; |
| 311 | Asmcxx . . $ Asm#::ParseStatecxx . . $ Asm#ParseState# state = Asmcxx . . $ Asm#::PS_STARTcxx . . $ Asm#PS_START.; |
| 312 | do { |
| 313 | if (!getTokencxx . . $ Asm#getToken(108e64ee63107a0f).(sourceLine, token, tokenString)) { |
| 314 | errorString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 315 | return false; |
| 316 | } |
| 317 | switch (state) { |
| 318 | case Asmcxx . . $ Asm#::PS_STARTcxx . . $ Asm#PS_START.: |
| 319 | if (token == Asmcxx . . $ Asm#::LT_IDENTIFIERcxx . . $ Asm#LT_IDENTIFIER.) { |
| 320 | if (Pepcxx . . $ Pep#::mnemonToEnumMapcxx . . $ Pep#mnemonToEnumMap..containscxx . . $ QMap#contains(8877ebe272b9620d).(tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).())) { |
| 321 | localEnumMnemonic = Pepcxx . . $ Pep#::mnemonToEnumMapcxx . . $ Pep#mnemonToEnumMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).()); |
| 322 | if (Pepcxx . . $ Pep#::isUnaryMapcxx . . $ Pep#isUnaryMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(localEnumMnemonic)) { |
| 323 | unaryInstruction = new UnaryInstructioncxx . . $ UnaryInstruction#; |
| 324 | unaryInstruction->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 325 | unaryInstruction->mnemoniccxx . . $ UnaryInstruction#mnemonic. = localEnumMnemonic; |
| 326 | code = unaryInstruction; |
| 327 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 328 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; // One byte generated for unary instruction. |
| 329 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 330 | } |
| 331 | else { |
| 332 | nonUnaryInstruction = new NonUnaryInstructioncxx . . $ NonUnaryInstruction#; |
| 333 | nonUnaryInstruction->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 334 | nonUnaryInstruction->mnemoniccxx . . $ NonUnaryInstruction#mnemonic. = localEnumMnemonic; |
| 335 | code = nonUnaryInstruction; |
| 336 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 337 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 3; // Three bytes generated for nonunary instruction. |
| 338 | state = Asmcxx . . $ Asm#::PS_INSTRUCTIONcxx . . $ Asm#PS_INSTRUCTION.; |
| 339 | } |
| 340 | } |
| 341 | else { |
| 342 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Invalid mnemonic."; |
| 343 | return false; |
| 344 | } |
| 345 | } |
| 346 | else if (token == Asmcxx . . $ Asm#::LT_DOT_COMMANDcxx . . $ Asm#LT_DOT_COMMAND.) { |
| 347 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the period |
| 348 | tokenString =cxx . . $ QString#`operator=`(4f35bf974e7f8568). tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).(); |
| 349 | if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "ADDRSS") { |
| 350 | dotAddrss = new DotAddrsscxx . . $ DotAddrss#; |
| 351 | dotAddrss->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 352 | code = dotAddrss; |
| 353 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 354 | state = Asmcxx . . $ Asm#::PS_DOT_ADDRSScxx . . $ Asm#PS_DOT_ADDRSS.; |
| 355 | } |
| 356 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "ASCII") { |
| 357 | dotAscii = new DotAsciicxx . . $ DotAscii#; |
| 358 | dotAscii->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 359 | code = dotAscii; |
| 360 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 361 | state = Asmcxx . . $ Asm#::PS_DOT_ASCIIcxx . . $ Asm#PS_DOT_ASCII.; |
| 362 | } |
| 363 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BLOCK") { |
| 364 | dotBlock = new DotBlockcxx . . $ DotBlock#; |
| 365 | dotBlock->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 366 | code = dotBlock; |
| 367 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 368 | state = Asmcxx . . $ Asm#::PS_DOT_BLOCKcxx . . $ Asm#PS_DOT_BLOCK.; |
| 369 | } |
| 370 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BURN") { |
| 371 | dotBurn = new DotBurncxx . . $ DotBurn#; |
| 372 | dotBurn->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 373 | code = dotBurn; |
| 374 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 375 | state = Asmcxx . . $ Asm#::PS_DOT_BURNcxx . . $ Asm#PS_DOT_BURN.; |
| 376 | } |
| 377 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BYTE") { |
| 378 | dotByte = new DotBytecxx . . $ DotByte#; |
| 379 | dotByte->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 380 | code = dotByte; |
| 381 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 382 | state = Asmcxx . . $ Asm#::PS_DOT_BYTEcxx . . $ Asm#PS_DOT_BYTE.; |
| 383 | } |
| 384 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "END") { |
| 385 | dotEnd = new DotEndcxx . . $ DotEnd#; |
| 386 | dotEnd->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 387 | code = dotEnd; |
| 388 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 389 | dotEndDetected = true; |
| 390 | state = Asmcxx . . $ Asm#::PS_DOT_ENDcxx . . $ Asm#PS_DOT_END.; |
| 391 | } |
| 392 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "EQUATE") { |
| 393 | dotEquate = new DotEquatecxx . . $ DotEquate#; |
| 394 | dotEquate->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 395 | code = dotEquate; |
| 396 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 397 | state = Asmcxx . . $ Asm#::PS_DOT_EQUATEcxx . . $ Asm#PS_DOT_EQUATE.; |
| 398 | } |
| 399 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "WORD") { |
| 400 | dotWord = new DotWordcxx . . $ DotWord#; |
| 401 | dotWord->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 402 | code = dotWord; |
| 403 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 404 | state = Asmcxx . . $ Asm#::PS_DOT_WORDcxx . . $ Asm#PS_DOT_WORD.; |
| 405 | } |
| 406 | else { |
| 407 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Invalid dot command."; |
| 408 | return false; |
| 409 | } |
| 410 | } |
| 411 | else if (token == Asmcxx . . $ Asm#::LT_SYMBOL_DEFcxx . . $ Asm#LT_SYMBOL_DEF.) { |
| 412 | tokenString.chopcxx . . $ QString#chop(d4f767463ce0a6b3).(1); // Remove the colon |
| 413 | if (tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).() > 8) { |
| 414 | errorString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). ";ERROR: Symbol " +cxx . . $ operator+(c75c3ae4eb9af1a8). tokenString +cxx . . $ operator+(3d22f08efddf8107). " cannot have more than eight characters."; |
| 415 | return false; |
| 416 | } |
| 417 | if (Pepcxx . . $ Pep#::symbolTablecxx . . $ Pep#symbolTable..containscxx . . $ QMap#contains(8877ebe272b9620d).(tokenString)) { |
| 418 | errorString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). ";ERROR: Symbol " +cxx . . $ operator+(c75c3ae4eb9af1a8). tokenString +cxx . . $ operator+(3d22f08efddf8107). " was previously defined."; |
| 419 | return false; |
| 420 | } |
| 421 | localSymbolDef =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 422 | Pepcxx . . $ Pep#::symbolTablecxx . . $ Pep#symbolTable..insertcxx . . $ QMap#insert(929a1ed410fe8423).(localSymbolDef, Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.); |
| 423 | Pepcxx . . $ Pep#::adjustSymbolValueForBurncxx . . $ Pep#adjustSymbolValueForBurn..insertcxx . . $ QMap#insert(929a1ed410fe8423).(localSymbolDef, true); |
| 424 | state = Asmcxx . . $ Asm#::PS_SYMBOL_DEFcxx . . $ Asm#PS_SYMBOL_DEF.; |
| 425 | } |
| 426 | else if (token == Asmcxx . . $ Asm#::LT_COMMENTcxx . . $ Asm#LT_COMMENT.) { |
| 427 | commentOnly = new CommentOnlycxx . . $ CommentOnly#; |
| 428 | commentOnly->commentcxx . . $ Code#comment. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 429 | code = commentOnly; |
| 430 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 431 | state = Asmcxx . . $ Asm#::PS_COMMENTcxx . . $ Asm#PS_COMMENT.; |
| 432 | } |
| 433 | else if (token == Asmcxx . . $ Asm#::LT_EMPTYcxx . . $ Asm#LT_EMPTY.) { |
| 434 | blankLine = new BlankLinecxx . . $ BlankLine#; |
| 435 | code = blankLine; |
| 436 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 437 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 438 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 439 | } |
| 440 | else { |
| 441 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Line must start with symbol definition, mnemonic, dot command, or comment."; |
| 442 | return false; |
| 443 | } |
| 444 | break; |
| 445 | |
| 446 | case Asmcxx . . $ Asm#::PS_SYMBOL_DEFcxx . . $ Asm#PS_SYMBOL_DEF.: |
| 447 | if (token == Asmcxx . . $ Asm#::LT_IDENTIFIERcxx . . $ Asm#LT_IDENTIFIER.){ |
| 448 | if (Pepcxx . . $ Pep#::mnemonToEnumMapcxx . . $ Pep#mnemonToEnumMap..containscxx . . $ QMap#contains(8877ebe272b9620d).(tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).())) { |
| 449 | localEnumMnemonic = Pepcxx . . $ Pep#::mnemonToEnumMapcxx . . $ Pep#mnemonToEnumMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).()); |
| 450 | if (Pepcxx . . $ Pep#::isUnaryMapcxx . . $ Pep#isUnaryMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(localEnumMnemonic)) { |
| 451 | unaryInstruction = new UnaryInstructioncxx . . $ UnaryInstruction#; |
| 452 | unaryInstruction->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 453 | unaryInstruction->mnemoniccxx . . $ UnaryInstruction#mnemonic. = localEnumMnemonic; |
| 454 | code = unaryInstruction; |
| 455 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 456 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; // One byte generated for unary instruction. |
| 457 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 458 | } |
| 459 | else { |
| 460 | nonUnaryInstruction = new NonUnaryInstructioncxx . . $ NonUnaryInstruction#; |
| 461 | nonUnaryInstruction->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 462 | nonUnaryInstruction->mnemoniccxx . . $ NonUnaryInstruction#mnemonic. = localEnumMnemonic; |
| 463 | code = nonUnaryInstruction; |
| 464 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 465 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 3; // Three bytes generated for unary instruction. |
| 466 | state = Asmcxx . . $ Asm#::PS_INSTRUCTIONcxx . . $ Asm#PS_INSTRUCTION.; |
| 467 | } |
| 468 | } |
| 469 | else { |
| 470 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Invalid mnemonic."; |
| 471 | return false; |
| 472 | } |
| 473 | } |
| 474 | else if (token == Asmcxx . . $ Asm#::LT_DOT_COMMANDcxx . . $ Asm#LT_DOT_COMMAND.) { |
| 475 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 1); // Remove the period |
| 476 | tokenString =cxx . . $ QString#`operator=`(4f35bf974e7f8568). tokenString.toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).(); |
| 477 | if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "ADDRSS") { |
| 478 | dotAddrss = new DotAddrsscxx . . $ DotAddrss#; |
| 479 | dotAddrss->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 480 | code = dotAddrss; |
| 481 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 482 | state = Asmcxx . . $ Asm#::PS_DOT_ADDRSScxx . . $ Asm#PS_DOT_ADDRSS.; |
| 483 | } |
| 484 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "ASCII") { |
| 485 | dotAscii = new DotAsciicxx . . $ DotAscii#; |
| 486 | dotAscii->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 487 | code = dotAscii; |
| 488 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 489 | state = Asmcxx . . $ Asm#::PS_DOT_ASCIIcxx . . $ Asm#PS_DOT_ASCII.; |
| 490 | } |
| 491 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BLOCK") { |
| 492 | dotBlock = new DotBlockcxx . . $ DotBlock#; |
| 493 | dotBlock->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 494 | code = dotBlock; |
| 495 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 496 | state = Asmcxx . . $ Asm#::PS_DOT_BLOCKcxx . . $ Asm#PS_DOT_BLOCK.; |
| 497 | } |
| 498 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BURN") { |
| 499 | dotBurn = new DotBurncxx . . $ DotBurn#; |
| 500 | dotBurn->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 501 | code = dotBurn; |
| 502 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 503 | state = Asmcxx . . $ Asm#::PS_DOT_BURNcxx . . $ Asm#PS_DOT_BURN.; |
| 504 | } |
| 505 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "BYTE") { |
| 506 | dotByte = new DotBytecxx . . $ DotByte#; |
| 507 | dotByte->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 508 | code = dotByte; |
| 509 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 510 | state = Asmcxx . . $ Asm#::PS_DOT_BYTEcxx . . $ Asm#PS_DOT_BYTE.; |
| 511 | } |
| 512 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "END") { |
| 513 | dotEnd = new DotEndcxx . . $ DotEnd#; |
| 514 | dotEnd->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 515 | code = dotEnd; |
| 516 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 517 | dotEndDetected = true; |
| 518 | state = Asmcxx . . $ Asm#::PS_DOT_ENDcxx . . $ Asm#PS_DOT_END.; |
| 519 | } |
| 520 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "EQUATE") { |
| 521 | dotEquate = new DotEquatecxx . . $ DotEquate#; |
| 522 | dotEquate->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 523 | code = dotEquate; |
| 524 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 525 | state = Asmcxx . . $ Asm#::PS_DOT_EQUATEcxx . . $ Asm#PS_DOT_EQUATE.; |
| 526 | } |
| 527 | else if (tokenString ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "WORD") { |
| 528 | dotWord = new DotWordcxx . . $ DotWord#; |
| 529 | dotWord->symbolDefcxx . . $ Code#symbolDef. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). localSymbolDef; |
| 530 | code = dotWord; |
| 531 | code->memAddresscxx . . $ Code#memAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 532 | state = Asmcxx . . $ Asm#::PS_DOT_WORDcxx . . $ Asm#PS_DOT_WORD.; |
| 533 | } |
| 534 | else { |
| 535 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Invalid dot command."; |
| 536 | return false; |
| 537 | } |
| 538 | } |
| 539 | else { |
| 540 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Must have mnemonic or dot command after symbol definition."; |
| 541 | return false; |
| 542 | } |
| 543 | break; |
| 544 | |
| 545 | case Asmcxx . . $ Asm#::PS_INSTRUCTIONcxx . . $ Asm#PS_INSTRUCTION.: |
| 546 | if (token == Asmcxx . . $ Asm#::LT_IDENTIFIERcxx . . $ Asm#LT_IDENTIFIER.) { |
| 547 | if (tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).() > 8) { |
| 548 | errorString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). ";ERROR: Symbol " +cxx . . $ operator+(c75c3ae4eb9af1a8). tokenString +cxx . . $ operator+(3d22f08efddf8107). " cannot have more than eight characters."; |
| 549 | return false; |
| 550 | } |
| 551 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new SymbolRefArgumentcxx . . $ SymbolRefArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 552 | Asmcxx . . $ Asm#::listOfReferencedSymbolscxx . . $ Asm#listOfReferencedSymbols..appendcxx . . $ QList#append(77d9f17553126ecb).(tokenString); |
| 553 | Asmcxx . . $ Asm#::listOfReferencedSymbolLineNumscxx . . $ Asm#listOfReferencedSymbolLineNums..appendcxx . . $ QList#append(77d9f17553126ecb).(lineNum); |
| 554 | state = Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.; |
| 555 | } |
| 556 | else if (token == Asmcxx . . $ Asm#::LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.) { |
| 557 | if (Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).) > 2) { |
| 558 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: String operands must have length at most two."; |
| 559 | return false; |
| 560 | } |
| 561 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new StringArgumentcxx . . $ StringArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 562 | state = Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.; |
| 563 | } |
| 564 | else if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 565 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 566 | bool ok; |
| 567 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 568 | if (value < 65536) { |
| 569 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 570 | state = Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.; |
| 571 | } |
| 572 | else { |
| 573 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hexidecimal constant is out of range (0x0000..0xFFFF)."; |
| 574 | return false; |
| 575 | } |
| 576 | } |
| 577 | else if (token == Asmcxx . . $ Asm#::LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.) { |
| 578 | bool ok; |
| 579 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 10); |
| 580 | if ((-32768 <= value) && (value <= 65535)) { |
| 581 | if (value < 0) { |
| 582 | value += 65536; // Stored as two-byte unsigned. |
| 583 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new DecArgumentcxx . . $ DecArgument#(value); |
| 584 | } |
| 585 | else { |
| 586 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new UnsignedDecArgumentcxx . . $ UnsignedDecArgument#(value); |
| 587 | } |
| 588 | state = Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.; |
| 589 | } |
| 590 | else { |
| 591 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Decimal constant is out of range (-32768..65535)."; |
| 592 | return false; |
| 593 | } |
| 594 | } |
| 595 | else if (token == Asmcxx . . $ Asm#::LT_CHAR_CONSTANTcxx . . $ Asm#LT_CHAR_CONSTANT.) { |
| 596 | nonUnaryInstruction->argumentcxx . . $ NonUnaryInstruction#argument. = new CharArgumentcxx . . $ CharArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 597 | state = Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.; |
| 598 | } |
| 599 | else { |
| 600 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Operand specifier expected after mnemonic."; |
| 601 | return false; |
| 602 | } |
| 603 | break; |
| 604 | |
| 605 | case Asmcxx . . $ Asm#::PS_ADDRESSING_MODEcxx . . $ Asm#PS_ADDRESSING_MODE.: |
| 606 | if (token == Asmcxx . . $ Asm#::LT_ADDRESSING_MODEcxx . . $ Asm#LT_ADDRESSING_MODE.) { |
| 607 | Enucxx . . $ Enu/::EAddrModecxx . . $ Enu/EAddrMode# addrMode = Asmcxx . . $ Asm#::stringToAddrModecxx . . $ Asm#stringToAddrMode(f9b7f5c0e4b95d6e).(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 608 | if ((addrMode & Pepcxx . . $ Pep#::addrModesMapcxx . . $ Pep#addrModesMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(localEnumMnemonic)) == 0) { // Nested parens required. |
| 609 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Illegal addressing mode for this instruction."; |
| 610 | return false; |
| 611 | } |
| 612 | nonUnaryInstruction->addressingModecxx . . $ NonUnaryInstruction#addressingMode. = addrMode; |
| 613 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 614 | } |
| 615 | else if (Pepcxx . . $ Pep#::addrModeRequiredMapcxx . . $ Pep#addrModeRequiredMap..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(localEnumMnemonic)) { |
| 616 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Addressing mode required for this instruction."; |
| 617 | return false; |
| 618 | } |
| 619 | else { // Must be branch type instruction with no addressing mode. Assign default addressing mode. |
| 620 | nonUnaryInstruction->addressingModecxx . . $ NonUnaryInstruction#addressingMode. = Enucxx . . $ Enu/::Icxx . . $ Enu/I.; |
| 621 | if (token == Asmcxx . . $ Asm#::LT_COMMENTcxx . . $ Asm#LT_COMMENT.) { |
| 622 | code->commentcxx . . $ Code#comment. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 623 | state = Asmcxx . . $ Asm#::PS_COMMENTcxx . . $ Asm#PS_COMMENT.; |
| 624 | } |
| 625 | else if (token == Asmcxx . . $ Asm#::LT_EMPTYcxx . . $ Asm#LT_EMPTY.) { |
| 626 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 627 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 628 | } |
| 629 | else { |
| 630 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Comment expected following instruction."; |
| 631 | return false; |
| 632 | } |
| 633 | } |
| 634 | break; |
| 635 | |
| 636 | case Asmcxx . . $ Asm#::PS_DOT_ADDRSScxx . . $ Asm#PS_DOT_ADDRSS.: |
| 637 | if (token == Asmcxx . . $ Asm#::LT_IDENTIFIERcxx . . $ Asm#LT_IDENTIFIER.) { |
| 638 | if (tokenString.lengthcxx . . $ QString#length(455f465bc33b4cdf).() > 8) { |
| 639 | errorString =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). ";ERROR: Symbol " +cxx . . $ operator+(c75c3ae4eb9af1a8). tokenString +cxx . . $ operator+(3d22f08efddf8107). " cannot have more than eight characters."; |
| 640 | return false; |
| 641 | } |
| 642 | dotAddrss->argumentcxx . . $ DotAddrss#argument. = new SymbolRefArgumentcxx . . $ SymbolRefArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 643 | Asmcxx . . $ Asm#::listOfReferencedSymbolscxx . . $ Asm#listOfReferencedSymbols..appendcxx . . $ QList#append(77d9f17553126ecb).(tokenString); |
| 644 | Asmcxx . . $ Asm#::listOfReferencedSymbolLineNumscxx . . $ Asm#listOfReferencedSymbolLineNums..appendcxx . . $ QList#append(77d9f17553126ecb).(lineNum); |
| 645 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 2; |
| 646 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 647 | } |
| 648 | else { |
| 649 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .ADDRSS requires a symbol argument."; |
| 650 | return false; |
| 651 | } |
| 652 | break; |
| 653 | |
| 654 | case Asmcxx . . $ Asm#::PS_DOT_ASCIIcxx . . $ Asm#PS_DOT_ASCII.: |
| 655 | if (token == Asmcxx . . $ Asm#::LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.) { |
| 656 | dotAscii->argumentcxx . . $ DotAscii#argument. = new StringArgumentcxx . . $ StringArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 657 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 658 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 659 | } |
| 660 | else { |
| 661 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .ASCII requires a string constant argument."; |
| 662 | return false; |
| 663 | } |
| 664 | break; |
| 665 | |
| 666 | case Asmcxx . . $ Asm#::PS_DOT_BLOCKcxx . . $ Asm#PS_DOT_BLOCK.: |
| 667 | if (token == Asmcxx . . $ Asm#::LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.) { |
| 668 | bool ok; |
| 669 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 10); |
| 670 | if ((0 <= value) && (value <= 65535)) { |
| 671 | if (value < 0) { |
| 672 | value += 65536; // Stored as two-byte unsigned. |
| 673 | dotBlock->argumentcxx . . $ DotBlock#argument. = new DecArgumentcxx . . $ DecArgument#(value); |
| 674 | } |
| 675 | else { |
| 676 | dotBlock->argumentcxx . . $ DotBlock#argument. = new UnsignedDecArgumentcxx . . $ UnsignedDecArgument#(value); |
| 677 | } |
| 678 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += value; |
| 679 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 680 | } |
| 681 | else { |
| 682 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Decimal constant is out of range (0..65535)."; |
| 683 | return false; |
| 684 | } |
| 685 | } |
| 686 | else if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 687 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 688 | bool ok; |
| 689 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 690 | if (value < 65536) { |
| 691 | dotBlock->argumentcxx . . $ DotBlock#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 692 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += value; |
| 693 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 694 | } |
| 695 | else { |
| 696 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hexidecimal constant is out of range (0x0000..0xFFFF)."; |
| 697 | return false; |
| 698 | } |
| 699 | } |
| 700 | else { |
| 701 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .BLOCK requires a decimal or hex constant argument."; |
| 702 | return false; |
| 703 | } |
| 704 | break; |
| 705 | |
| 706 | case Asmcxx . . $ Asm#::PS_DOT_BURNcxx . . $ Asm#PS_DOT_BURN.: |
| 707 | if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 708 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 709 | bool ok; |
| 710 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 711 | if (value < 65536) { |
| 712 | dotBurn->argumentcxx . . $ DotBurn#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 713 | Pepcxx . . $ Pep#::burnCountcxx . . $ Pep#burnCount.++; |
| 714 | Pepcxx . . $ Pep#::dotBurnArgumentcxx . . $ Pep#dotBurnArgument. = value; |
| 715 | Pepcxx . . $ Pep#::romStartAddresscxx . . $ Pep#romStartAddress. = Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount.; |
| 716 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 717 | } |
| 718 | else { |
| 719 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hexidecimal constant is out of range (0x0000..0xFFFF)."; |
| 720 | return false; |
| 721 | } |
| 722 | } |
| 723 | else { |
| 724 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .BURN requires a hex constant argument."; |
| 725 | return false; |
| 726 | } |
| 727 | break; |
| 728 | |
| 729 | case Asmcxx . . $ Asm#::PS_DOT_BYTEcxx . . $ Asm#PS_DOT_BYTE.: |
| 730 | if (token == Asmcxx . . $ Asm#::LT_CHAR_CONSTANTcxx . . $ Asm#LT_CHAR_CONSTANT.) { |
| 731 | dotByte->argumentcxx . . $ DotByte#argument. = new CharArgumentcxx . . $ CharArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 732 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; |
| 733 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 734 | } |
| 735 | else if (token == Asmcxx . . $ Asm#::LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.) { |
| 736 | bool ok; |
| 737 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 10); |
| 738 | if ((-128 <= value) && (value <= 255)) { |
| 739 | if (value < 0) { |
| 740 | value += 256; // value stored as one-byte unsigned. |
| 741 | } |
| 742 | dotByte->argumentcxx . . $ DotByte#argument. = new DecArgumentcxx . . $ DecArgument#(value); |
| 743 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; |
| 744 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 745 | } |
| 746 | else { |
| 747 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Decimal constant is out of byte range (-128..255)."; |
| 748 | return false; |
| 749 | } |
| 750 | } |
| 751 | else if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 752 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 753 | bool ok; |
| 754 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 755 | if (value < 256) { |
| 756 | dotByte->argumentcxx . . $ DotByte#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 757 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; |
| 758 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 759 | } |
| 760 | else { |
| 761 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hex constant is out of byte range (0x00..0xFF)."; |
| 762 | return false; |
| 763 | } |
| 764 | } |
| 765 | else if (token == Asmcxx . . $ Asm#::LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.) { |
| 766 | if (Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).) > 1) { |
| 767 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .BYTE string operands must have length one."; |
| 768 | return false; |
| 769 | } |
| 770 | dotByte->argumentcxx . . $ DotByte#argument. = new StringArgumentcxx . . $ StringArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 771 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 1; |
| 772 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 773 | } |
| 774 | else { |
| 775 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .BYTE requires a char, dec, hex, or string constant argument."; |
| 776 | return false; |
| 777 | } |
| 778 | break; |
| 779 | |
| 780 | case Asmcxx . . $ Asm#::PS_DOT_ENDcxx . . $ Asm#PS_DOT_END.: |
| 781 | if (token == Asmcxx . . $ Asm#::LT_COMMENTcxx . . $ Asm#LT_COMMENT.) { |
| 782 | dotEnd->commentcxx . . $ Code#comment. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 783 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 784 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 785 | } |
| 786 | else if (token == Asmcxx . . $ Asm#::LT_EMPTYcxx . . $ Asm#LT_EMPTY.) { |
| 787 | dotEnd->commentcxx . . $ Code#comment. =cxx . . $ QString#`operator=`(d02845eef0c33901). ""; |
| 788 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 789 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 790 | } |
| 791 | else { |
| 792 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Only a comment can follow .END."; |
| 793 | return false; |
| 794 | } |
| 795 | break; |
| 796 | |
| 797 | case Asmcxx . . $ Asm#::PS_DOT_EQUATEcxx . . $ Asm#PS_DOT_EQUATE.: |
| 798 | if (dotEquate->symbolDefcxx . . $ Code#symbolDef. ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "") { |
| 799 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .EQUATE must have a symbol definition."; |
| 800 | return false; |
| 801 | } |
| 802 | else if (token == Asmcxx . . $ Asm#::LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.) { |
| 803 | bool ok; |
| 804 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 10); |
| 805 | if ((-32768 <= value) && (value <= 65535)) { |
| 806 | |
| 807 | if (value < 0) { |
| 808 | value += 65536; // Stored as two-byte unsigned. |
| 809 | dotEquate->argumentcxx . . $ DotEquate#argument. = new DecArgumentcxx . . $ DecArgument#(value); |
| 810 | } |
| 811 | else { |
| 812 | dotEquate->argumentcxx . . $ DotEquate#argument. = new UnsignedDecArgumentcxx . . $ UnsignedDecArgument#(value); |
| 813 | } |
| 814 | Pepcxx . . $ Pep#::symbolTablecxx . . $ Pep#symbolTable..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., value); |
| 815 | Pepcxx . . $ Pep#::adjustSymbolValueForBurncxx . . $ Pep#adjustSymbolValueForBurn..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., false); |
| 816 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 817 | } |
| 818 | else { |
| 819 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Decimal constant is out of range (-32768..65535)."; |
| 820 | return false; |
| 821 | } |
| 822 | } |
| 823 | else if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 824 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 825 | bool ok; |
| 826 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 827 | if (value < 65536) { |
| 828 | dotEquate->argumentcxx . . $ DotEquate#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 829 | Pepcxx . . $ Pep#::symbolTablecxx . . $ Pep#symbolTable..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., value); |
| 830 | Pepcxx . . $ Pep#::adjustSymbolValueForBurncxx . . $ Pep#adjustSymbolValueForBurn..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., false); |
| 831 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 832 | } |
| 833 | else { |
| 834 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hexidecimal constant is out of range (0x0000..0xFFFF)."; |
| 835 | return false; |
| 836 | } |
| 837 | } |
| 838 | else if (token == Asmcxx . . $ Asm#::LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.) { |
| 839 | if (Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).) > 2) { |
| 840 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .EQUATE string operand must have length at most two."; |
| 841 | return false; |
| 842 | } |
| 843 | dotEquate->argumentcxx . . $ DotEquate#argument. = new StringArgumentcxx . . $ StringArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 844 | Pepcxx . . $ Pep#::symbolTablecxx . . $ Pep#symbolTable..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., Asmcxx . . $ Asm#::string2ArgumentToIntcxx . . $ Asm#string2ArgumentToInt(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).)); |
| 845 | Pepcxx . . $ Pep#::adjustSymbolValueForBurncxx . . $ Pep#adjustSymbolValueForBurn..insertcxx . . $ QMap#insert(929a1ed410fe8423).(dotEquate->symbolDefcxx . . $ Code#symbolDef., false); |
| 846 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 847 | } |
| 848 | else { |
| 849 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .EQUATE requires a dec, hex, or string constant argument."; |
| 850 | return false; |
| 851 | } |
| 852 | break; |
| 853 | |
| 854 | case Asmcxx . . $ Asm#::PS_DOT_WORDcxx . . $ Asm#PS_DOT_WORD.: |
| 855 | if (token == Asmcxx . . $ Asm#::LT_CHAR_CONSTANTcxx . . $ Asm#LT_CHAR_CONSTANT.) { |
| 856 | dotWord->argumentcxx . . $ DotWord#argument. = new CharArgumentcxx . . $ CharArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 857 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 2; |
| 858 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 859 | } |
| 860 | else if (token == Asmcxx . . $ Asm#::LT_DEC_CONSTANTcxx . . $ Asm#LT_DEC_CONSTANT.) { |
| 861 | bool ok; |
| 862 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 10); |
| 863 | if ((-32768 <= value) && (value < 65536)) { |
| 864 | |
| 865 | if (value < 0) { |
| 866 | value += 65536; // Stored as two-byte unsigned. |
| 867 | dotWord->argumentcxx . . $ DotWord#argument. = new DecArgumentcxx . . $ DecArgument#(value); |
| 868 | } |
| 869 | else { |
| 870 | dotWord->argumentcxx . . $ DotWord#argument. = new UnsignedDecArgumentcxx . . $ UnsignedDecArgument#(value); |
| 871 | } |
| 872 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 2; |
| 873 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 874 | } |
| 875 | else { |
| 876 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Decimal constant is out of range (-32768..65535)."; |
| 877 | return false; |
| 878 | } |
| 879 | } |
| 880 | else if (token == Asmcxx . . $ Asm#::LT_HEX_CONSTANTcxx . . $ Asm#LT_HEX_CONSTANT.) { |
| 881 | tokenString.removecxx . . $ QString#remove(6483560ce2afa901).(0, 2); // Remove "0x" prefix. |
| 882 | bool ok; |
| 883 | int value = tokenString.toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&ok, 16); |
| 884 | if (value < 65536) { |
| 885 | dotWord->argumentcxx . . $ DotWord#argument. = new HexArgumentcxx . . $ HexArgument#(value); |
| 886 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 2; |
| 887 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 888 | } |
| 889 | else { |
| 890 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Hexidecimal constant is out of range (0x0000..0xFFFF)."; |
| 891 | return false; |
| 892 | } |
| 893 | } |
| 894 | else if (token == Asmcxx . . $ Asm#::LT_STRING_CONSTANTcxx . . $ Asm#LT_STRING_CONSTANT.) { |
| 895 | if (Asmcxx . . $ Asm#::byteStringLengthcxx . . $ Asm#byteStringLength(87a9b7c6fe1ccdba).(tokenStringcxx . . $ QString#QString(132dd6869045752b).) > 2) { |
| 896 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .WORD string operands must have length at most two."; |
| 897 | return false; |
| 898 | } |
| 899 | dotWord->argumentcxx . . $ DotWord#argument. = new StringArgumentcxx . . $ StringArgument#(tokenStringcxx . . $ QString#QString(132dd6869045752b).); |
| 900 | Pepcxx . . $ Pep#::byteCountcxx . . $ Pep#byteCount. += 2; |
| 901 | state = Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.; |
| 902 | } |
| 903 | else { |
| 904 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: .WORD requires a char, dec, hex, or string constant argument."; |
| 905 | return false; |
| 906 | } |
| 907 | break; |
| 908 | |
| 909 | case Asmcxx . . $ Asm#::PS_CLOSEcxx . . $ Asm#PS_CLOSE.: |
| 910 | if (token == Asmcxx . . $ Asm#::LT_EMPTYcxx . . $ Asm#LT_EMPTY.) { |
| 911 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 912 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 913 | } |
| 914 | else if (token == Asmcxx . . $ Asm#::LT_COMMENTcxx . . $ Asm#LT_COMMENT.) { |
| 915 | code->commentcxx . . $ Code#comment. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). tokenString; |
| 916 | state = Asmcxx . . $ Asm#::PS_COMMENTcxx . . $ Asm#PS_COMMENT.; |
| 917 | } |
| 918 | else { |
| 919 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Comment expected following instruction."; |
| 920 | return false; |
| 921 | } |
| 922 | break; |
| 923 | |
| 924 | case Asmcxx . . $ Asm#::PS_COMMENTcxx . . $ Asm#PS_COMMENT.: |
| 925 | if (token == Asmcxx . . $ Asm#::LT_EMPTYcxx . . $ Asm#LT_EMPTY.) { |
| 926 | code->sourceCodeLinecxx . . $ Code#sourceCodeLine. = lineNum; |
| 927 | state = Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.; |
| 928 | } |
| 929 | else { |
| 930 | // This error should not occur, as all characters are allowed in comments. |
| 931 | errorString =cxx . . $ QString#`operator=`(d02845eef0c33901). ";ERROR: Problem detected after comment."; |
| 932 | return false; |
| 933 | } |
| 934 | break; |
| 935 | |
| 936 | default: |
| 937 | break; |
| 938 | } |
| 939 | } |
| 940 | while (state != Asmcxx . . $ Asm#::PS_FINISHcxx . . $ Asm#PS_FINISH.); |
| 941 | return true; |
| 942 | } |