| 1 | // File: redefinemnemonicsdialog.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 "redefinemnemonicsdialog.h" |
| 22 | #include "ui_redefinemnemonicsdialog.h" |
| 23 | #include <QRegExpValidator> |
| 24 | using namespace Enu; |
| 25 | |
| 26 | RedefineMnemonicsDialog::RedefineMnemonicsDialog(QWidget *parent) : |
| 27 | QDialog(parent), |
| 28 | ui(new Ui::RedefineMnemonicsDialog) |
| 29 | { |
| 30 | ui->setupUi(this); |
| 31 | restoreDefaults(); |
| 32 | |
| 33 | ui->unaryOpCodeLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 34 | ui->unaryOpCode1Label->setFont(QFont(Pep::codeFont)); |
| 35 | ui->unaryOpCode2Label->setFont(QFont(Pep::codeFont)); |
| 36 | ui->unaryOpCode3Label->setFont(QFont(Pep::codeFont)); |
| 37 | ui->unaryOpCode4Label->setFont(QFont(Pep::codeFont)); |
| 38 | |
| 39 | ui->unaryMnemonicLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 40 | ui->unaryMnemonic0LineEdit->setFont(QFont(Pep::codeFont)); |
| 41 | ui->unaryMnemonic1LineEdit->setFont(QFont(Pep::codeFont)); |
| 42 | ui->unaryMnemonic2LineEdit->setFont(QFont(Pep::codeFont)); |
| 43 | ui->unaryMnemonic3LineEdit->setFont(QFont(Pep::codeFont)); |
| 44 | |
| 45 | ui->nonunaryMnemonicLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 46 | ui->iLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 47 | ui->dLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 48 | ui->nLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 49 | ui->sLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 50 | ui->sfLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 51 | ui->xLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 52 | ui->sxLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 53 | ui->sxfLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 54 | |
| 55 | ui->nonunaryOpCodeLabel->setFont(QFont(Pep::labelFont, Pep::labelFontSize, QFont::Bold)); |
| 56 | |
| 57 | ui->nonunaryOpCode1Label->setFont(QFont(Pep::codeFont)); |
| 58 | ui->nonunaryOpCode2Label->setFont(QFont(Pep::codeFont)); |
| 59 | ui->nonunaryOpCode3Label->setFont(QFont(Pep::codeFont)); |
| 60 | ui->nonunaryOpCode4Label->setFont(QFont(Pep::codeFont)); |
| 61 | |
| 62 | ui->nonUnaryMnemonic0LineEdit->setFont(QFont(Pep::codeFont)); |
| 63 | ui->nonUnaryMnemonic1LineEdit->setFont(QFont(Pep::codeFont)); |
| 64 | ui->nonUnaryMnemonic2LineEdit->setFont(QFont(Pep::codeFont)); |
| 65 | ui->nonUnaryMnemonic3LineEdit->setFont(QFont(Pep::codeFont)); |
| 66 | |
| 67 | connect(ui->defaultMnemonicsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults())); |
| 68 | |
| 69 | QRegExp rx("^[A-Za-z][A-Za-z0-9]{0,7}"); |
| 70 | QValidator *validator = new QRegExpValidator(rx, this); |
| 71 | |
| 72 | ui->nonUnaryMnemonic0LineEdit->setValidator(validator); |
| 73 | ui->nonUnaryMnemonic1LineEdit->setValidator(validator); |
| 74 | ui->nonUnaryMnemonic2LineEdit->setValidator(validator); |
| 75 | ui->nonUnaryMnemonic3LineEdit->setValidator(validator); |
| 76 | |
| 77 | ui->unaryMnemonic0LineEdit->setValidator(validator); |
| 78 | ui->unaryMnemonic1LineEdit->setValidator(validator); |
| 79 | ui->unaryMnemonic2LineEdit->setValidator(validator); |
| 80 | ui->unaryMnemonic3LineEdit->setValidator(validator); |
| 81 | |
| 82 | connect(ui->nonUnaryMnemonic0LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineNonUnaryMnemonic0(QString))); |
| 83 | connect(ui->nonUnaryMnemonic1LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineNonUnaryMnemonic1(QString))); |
| 84 | connect(ui->nonUnaryMnemonic2LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineNonUnaryMnemonic2(QString))); |
| 85 | connect(ui->nonUnaryMnemonic3LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineNonUnaryMnemonic3(QString))); |
| 86 | |
| 87 | connect(ui->unaryMnemonic0LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineUnaryMnemonic0(QString))); |
| 88 | connect(ui->unaryMnemonic1LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineUnaryMnemonic1(QString))); |
| 89 | connect(ui->unaryMnemonic2LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineUnaryMnemonic2(QString))); |
| 90 | connect(ui->unaryMnemonic3LineEdit, SIGNAL(textEdited(QString)), this, SLOT(redefineUnaryMnemonic3(QString))); |
| 91 | |
| 92 | connect(ui->mnemon0iCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 93 | connect(ui->mnemon0dCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 94 | connect(ui->mnemon0nCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 95 | connect(ui->mnemon0sCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 96 | connect(ui->mnemon0sfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 97 | connect(ui->mnemon0xCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 98 | connect(ui->mnemon0sxCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 99 | connect(ui->mnemon0sxfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 100 | |
| 101 | connect(ui->mnemon1iCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 102 | connect(ui->mnemon1dCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 103 | connect(ui->mnemon1nCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 104 | connect(ui->mnemon1sCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 105 | connect(ui->mnemon1sfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 106 | connect(ui->mnemon1xCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 107 | connect(ui->mnemon1sxCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 108 | connect(ui->mnemon1sxfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 109 | |
| 110 | connect(ui->mnemon2iCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 111 | connect(ui->mnemon2dCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 112 | connect(ui->mnemon2nCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 113 | connect(ui->mnemon2sCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 114 | connect(ui->mnemon2sfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 115 | connect(ui->mnemon2xCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 116 | connect(ui->mnemon2sxCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 117 | connect(ui->mnemon2sxfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 118 | |
| 119 | connect(ui->mnemon3iCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 120 | connect(ui->mnemon3dCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 121 | connect(ui->mnemon3nCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 122 | connect(ui->mnemon3sCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 123 | connect(ui->mnemon3sfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 124 | connect(ui->mnemon3xCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 125 | connect(ui->mnemon3sxCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 126 | connect(ui->mnemon3sxfCheckBox, SIGNAL(clicked()), this, SLOT(setNonUnaryAllowedModes())); |
| 127 | } |
| 128 | |
| 129 | RedefineMnemonicsDialog::~RedefineMnemonicsDialog() |
| 130 | { |
| 131 | delete ui; |
| 132 | } |
| 133 | |
| 134 | void RedefineMnemonicsDialog::restoreDefaults() |
| 135 | { |
| 136 | ui->unaryMnemonic0LineEdit->setText(Pep::defaultUnaryMnemonic0); |
| 137 | ui->unaryMnemonic1LineEdit->setText(Pep::defaultUnaryMnemonic1); |
| 138 | ui->unaryMnemonic2LineEdit->setText(Pep::defaultUnaryMnemonic2); |
| 139 | ui->unaryMnemonic3LineEdit->setText(Pep::defaultUnaryMnemonic3); |
| 140 | ui->nonUnaryMnemonic0LineEdit->setText(Pep::defaultNonUnaryMnemonic0); |
| 141 | ui->mnemon0iCheckBox->setChecked(Pep::defaultMnemon0i); |
| 142 | ui->mnemon0dCheckBox->setChecked(Pep::defaultMnemon0d); |
| 143 | ui->mnemon0nCheckBox->setChecked(Pep::defaultMnemon0n); |
| 144 | ui->mnemon0sCheckBox->setChecked(Pep::defaultMnemon0s); |
| 145 | ui->mnemon0sfCheckBox->setChecked(Pep::defaultMnemon0sf); |
| 146 | ui->mnemon0xCheckBox->setChecked(Pep::defaultMnemon0x); |
| 147 | ui->mnemon0sxCheckBox->setChecked(Pep::defaultMnemon0sx); |
| 148 | ui->mnemon0sxfCheckBox->setChecked(Pep::defaultMnemon0sxf); |
| 149 | ui->nonUnaryMnemonic1LineEdit->setText(Pep::defaultNonUnaryMnemonic1); |
| 150 | ui->mnemon1iCheckBox->setChecked(Pep::defaultMnemon1i); |
| 151 | ui->mnemon1dCheckBox->setChecked(Pep::defaultMnemon1d); |
| 152 | ui->mnemon1nCheckBox->setChecked(Pep::defaultMnemon1n); |
| 153 | ui->mnemon1sCheckBox->setChecked(Pep::defaultMnemon1s); |
| 154 | ui->mnemon1sfCheckBox->setChecked(Pep::defaultMnemon1sf); |
| 155 | ui->mnemon1xCheckBox->setChecked(Pep::defaultMnemon1x); |
| 156 | ui->mnemon1sxCheckBox->setChecked(Pep::defaultMnemon1sx); |
| 157 | ui->mnemon1sxfCheckBox->setChecked(Pep::defaultMnemon1sxf); |
| 158 | ui->nonUnaryMnemonic2LineEdit->setText(Pep::defaultNonUnaryMnemonic2); |
| 159 | ui->mnemon2iCheckBox->setChecked(Pep::defaultMnemon2i); |
| 160 | ui->mnemon2dCheckBox->setChecked(Pep::defaultMnemon2d); |
| 161 | ui->mnemon2nCheckBox->setChecked(Pep::defaultMnemon2n); |
| 162 | ui->mnemon2sCheckBox->setChecked(Pep::defaultMnemon2s); |
| 163 | ui->mnemon2sfCheckBox->setChecked(Pep::defaultMnemon2sf); |
| 164 | ui->mnemon2xCheckBox->setChecked(Pep::defaultMnemon2x); |
| 165 | ui->mnemon2sxCheckBox->setChecked(Pep::defaultMnemon2sx); |
| 166 | ui->mnemon2sxfCheckBox->setChecked(Pep::defaultMnemon2sxf); |
| 167 | ui->nonUnaryMnemonic3LineEdit->setText(Pep::defaultNonUnaryMnemonic3); |
| 168 | ui->mnemon3iCheckBox->setChecked(Pep::defaultMnemon3i); |
| 169 | ui->mnemon3dCheckBox->setChecked(Pep::defaultMnemon3d); |
| 170 | ui->mnemon3nCheckBox->setChecked(Pep::defaultMnemon3n); |
| 171 | ui->mnemon3sCheckBox->setChecked(Pep::defaultMnemon3s); |
| 172 | ui->mnemon3sfCheckBox->setChecked(Pep::defaultMnemon3sf); |
| 173 | ui->mnemon3xCheckBox->setChecked(Pep::defaultMnemon3x); |
| 174 | ui->mnemon3sxCheckBox->setChecked(Pep::defaultMnemon3sx); |
| 175 | ui->mnemon3sxfCheckBox->setChecked(Pep::defaultMnemon3sxf); |
| 176 | |
| 177 | int addrMode = 0; |
| 178 | if (Pep::defaultMnemon0i) addrMode |= I; |
| 179 | if (Pep::defaultMnemon0d) addrMode |= D; |
| 180 | if (Pep::defaultMnemon0n) addrMode |= N; |
| 181 | if (Pep::defaultMnemon0s) addrMode |= S; |
| 182 | if (Pep::defaultMnemon0sf) addrMode |= SF; |
| 183 | if (Pep::defaultMnemon0x) addrMode |= X; |
| 184 | if (Pep::defaultMnemon0sx) addrMode |= SX; |
| 185 | if (Pep::defaultMnemon0sxf) addrMode |= SXF; |
| 186 | Pep::addrModesMap.insert(NOP, addrMode); |
| 187 | addrMode = 0; |
| 188 | if (Pep::defaultMnemon1i) addrMode |= I; |
| 189 | if (Pep::defaultMnemon1d) addrMode |= D; |
| 190 | if (Pep::defaultMnemon1n) addrMode |= N; |
| 191 | if (Pep::defaultMnemon1s) addrMode |= S; |
| 192 | if (Pep::defaultMnemon1sf) addrMode |= SF; |
| 193 | if (Pep::defaultMnemon1x) addrMode |= X; |
| 194 | if (Pep::defaultMnemon1sx) addrMode |= SX; |
| 195 | if (Pep::defaultMnemon1sxf) addrMode |= SXF; |
| 196 | Pep::addrModesMap.insert(DECI, addrMode); |
| 197 | addrMode = 0; |
| 198 | if (Pep::defaultMnemon2i) addrMode |= I; |
| 199 | if (Pep::defaultMnemon2d) addrMode |= D; |
| 200 | if (Pep::defaultMnemon2n) addrMode |= N; |
| 201 | if (Pep::defaultMnemon2s) addrMode |= S; |
| 202 | if (Pep::defaultMnemon2sf) addrMode |= SF; |
| 203 | if (Pep::defaultMnemon2x) addrMode |= X; |
| 204 | if (Pep::defaultMnemon2sx) addrMode |= SX; |
| 205 | if (Pep::defaultMnemon2sxf) addrMode |= SXF; |
| 206 | Pep::addrModesMap.insert(DECO, addrMode); |
| 207 | addrMode = 0; |
| 208 | if (Pep::defaultMnemon3i) addrMode |= I; |
| 209 | if (Pep::defaultMnemon3d) addrMode |= D; |
| 210 | if (Pep::defaultMnemon3n) addrMode |= N; |
| 211 | if (Pep::defaultMnemon3s) addrMode |= S; |
| 212 | if (Pep::defaultMnemon3sf) addrMode |= SF; |
| 213 | if (Pep::defaultMnemon3x) addrMode |= X; |
| 214 | if (Pep::defaultMnemon3sx) addrMode |= SX; |
| 215 | if (Pep::defaultMnemon3sxf) addrMode |= SXF; |
| 216 | Pep::addrModesMap.insert(STRO, addrMode); |
| 217 | |
| 218 | Pep::initEnumMnemonMaps(); |
| 219 | } |
| 220 | |
| 221 | void RedefineMnemonicsDialog::redefineNonUnaryMnemonic0(QString string) |
| 222 | { |
| 223 | string = string.toUpper(); |
| 224 | if (string.isEmpty()) { |
| 225 | ui->warningLabel->setText("Empty mnemonic not stored for 00101."); |
| 226 | } |
| 227 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 228 | ui->warningLabel->setText("Duplicate not stored for 00101."); |
| 229 | } |
| 230 | else { |
| 231 | ui->nonUnaryMnemonic0LineEdit->setText(string); |
| 232 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::NOP)); |
| 233 | Pep::enumToMnemonMap.insert(Enu::NOP, string); |
| 234 | Pep::mnemonToEnumMap.insert(string, Enu::NOP); |
| 235 | ui->warningLabel->clear(); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | void RedefineMnemonicsDialog::redefineNonUnaryMnemonic1(QString string) |
| 240 | { |
| 241 | string = string.toUpper(); |
| 242 | if (string.isEmpty()) { |
| 243 | ui->warningLabel->setText("Empty mnemonic not stored for 00110."); |
| 244 | } |
| 245 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 246 | ui->warningLabel->setText("Duplicate not stored for 00110."); |
| 247 | } |
| 248 | else { |
| 249 | ui->nonUnaryMnemonic1LineEdit->setText(string); |
| 250 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::DECI)); |
| 251 | Pep::enumToMnemonMap.insert(Enu::DECI, string); |
| 252 | Pep::mnemonToEnumMap.insert(string, Enu::DECI); |
| 253 | ui->warningLabel->clear(); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | void RedefineMnemonicsDialog::redefineNonUnaryMnemonic2(QString string) |
| 258 | { |
| 259 | string = string.toUpper(); |
| 260 | if (string.isEmpty()) { |
| 261 | ui->warningLabel->setText("Empty mnemonic not stored for 00111."); |
| 262 | } |
| 263 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 264 | ui->warningLabel->setText("Duplicate not stored for 00111."); |
| 265 | } |
| 266 | else { |
| 267 | ui->nonUnaryMnemonic2LineEdit->setText(string); |
| 268 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::DECO)); |
| 269 | Pep::enumToMnemonMap.insert(Enu::DECO, string); |
| 270 | Pep::mnemonToEnumMap.insert(string, Enu::DECO); |
| 271 | ui->warningLabel->clear(); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | void RedefineMnemonicsDialog::redefineNonUnaryMnemonic3(QString string) |
| 276 | { |
| 277 | string = string.toUpper(); |
| 278 | if (string.isEmpty()) { |
| 279 | ui->warningLabel->setText("Empty mnemonic not stored for 01000."); |
| 280 | } |
| 281 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 282 | ui->warningLabel->setText("Duplicate not stored for 01000."); |
| 283 | } |
| 284 | else { |
| 285 | ui->nonUnaryMnemonic3LineEdit->setText(string); |
| 286 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::STRO)); |
| 287 | Pep::enumToMnemonMap.insert(Enu::STRO, string); |
| 288 | Pep::mnemonToEnumMap.insert(string, Enu::STRO); |
| 289 | ui->warningLabel->clear(); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | void RedefineMnemonicsDialog::redefineUnaryMnemonic0(QString string) |
| 294 | { |
| 295 | string = string.toUpper(); |
| 296 | if (string.isEmpty()) { |
| 297 | ui->warningLabel->setText("Empty mnemonic not stored for 0010 0010."); |
| 298 | } |
| 299 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 300 | ui->warningLabel->setText("Duplicate not stored for 0010 0010."); |
| 301 | } |
| 302 | else { |
| 303 | ui->unaryMnemonic0LineEdit->setText(string); |
| 304 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::NOP0)); |
| 305 | Pep::enumToMnemonMap.insert(Enu::NOP0, string); |
| 306 | Pep::mnemonToEnumMap.insert(string, Enu::NOP0); |
| 307 | ui->warningLabel->clear(); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | void RedefineMnemonicsDialog::redefineUnaryMnemonic1(QString string) |
| 312 | { |
| 313 | string = string.toUpper(); |
| 314 | if (string.isEmpty()) { |
| 315 | ui->warningLabel->setText("Empty mnemonic not stored for 0010 0101."); |
| 316 | } |
| 317 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 318 | ui->warningLabel->setText("Duplicate not stored for 0010 0101."); |
| 319 | } |
| 320 | else { |
| 321 | ui->unaryMnemonic1LineEdit->setText(string); |
| 322 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::NOP1)); |
| 323 | Pep::enumToMnemonMap.insert(Enu::NOP1, string); |
| 324 | Pep::mnemonToEnumMap.insert(string, Enu::NOP1); |
| 325 | ui->warningLabel->clear(); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | void RedefineMnemonicsDialog::redefineUnaryMnemonic2(QString string) |
| 330 | { |
| 331 | string = string.toUpper(); |
| 332 | if (string.isEmpty()) { |
| 333 | ui->warningLabel->setText("Empty mnemonic not stored for 0010 0110."); |
| 334 | } |
| 335 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 336 | ui->warningLabel->setText("Duplicate not stored for 0010 0110."); |
| 337 | } |
| 338 | else { |
| 339 | ui->unaryMnemonic2LineEdit->setText(string); |
| 340 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::NOP2)); |
| 341 | Pep::enumToMnemonMap.insert(Enu::NOP2, string); |
| 342 | Pep::mnemonToEnumMap.insert(string, Enu::NOP2); |
| 343 | ui->warningLabel->clear(); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | void RedefineMnemonicsDialog::redefineUnaryMnemonic3(QString string) |
| 348 | { |
| 349 | string = string.toUpper(); |
| 350 | if (string.isEmpty()) { |
| 351 | ui->warningLabel->setText("Empty mnemonic not stored for 0010 0111."); |
| 352 | } |
| 353 | else if (Pep::mnemonToEnumMap.contains(string)) { |
| 354 | ui->warningLabel->setText("Duplicate not stored for 0010 0111."); |
| 355 | } |
| 356 | else { |
| 357 | ui->unaryMnemonic3LineEdit->setText(string); |
| 358 | Pep::mnemonToEnumMap.remove(Pep::enumToMnemonMap.value(Enu::NOP3)); |
| 359 | Pep::enumToMnemonMap.insert(Enu::NOP3, string); |
| 360 | Pep::mnemonToEnumMap.insert(string, Enu::NOP3); |
| 361 | ui->warningLabel->clear(); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | void RedefineMnemonicsDialog::setNonUnaryAllowedModes() |
| 366 | { |
| 367 | int addrMode = 0; |
| 368 | if (ui->mnemon0iCheckBox->isChecked()) addrMode |= I; |
| 369 | if (ui->mnemon0dCheckBox->isChecked()) addrMode |= D; |
| 370 | if (ui->mnemon0nCheckBox->isChecked()) addrMode |= N; |
| 371 | if (ui->mnemon0sCheckBox->isChecked()) addrMode |= S; |
| 372 | if (ui->mnemon0sfCheckBox->isChecked()) addrMode |= SF; |
| 373 | if (ui->mnemon0xCheckBox->isChecked()) addrMode |= X; |
| 374 | if (ui->mnemon0sxCheckBox->isChecked()) addrMode |= SX; |
| 375 | if (ui->mnemon0sxfCheckBox->isChecked()) addrMode |= SXF; |
| 376 | Pep::addrModesMap.insert(NOP, addrMode); |
| 377 | addrMode = 0; |
| 378 | if (ui->mnemon1iCheckBox->isChecked()) addrMode |= I; |
| 379 | if (ui->mnemon1dCheckBox->isChecked()) addrMode |= D; |
| 380 | if (ui->mnemon1nCheckBox->isChecked()) addrMode |= N; |
| 381 | if (ui->mnemon1sCheckBox->isChecked()) addrMode |= S; |
| 382 | if (ui->mnemon1sfCheckBox->isChecked()) addrMode |= SF; |
| 383 | if (ui->mnemon1xCheckBox->isChecked()) addrMode |= X; |
| 384 | if (ui->mnemon1sxCheckBox->isChecked()) addrMode |= SX; |
| 385 | if (ui->mnemon1sxfCheckBox->isChecked()) addrMode |= SXF; |
| 386 | Pep::addrModesMap.insert(DECI, addrMode); |
| 387 | addrMode = 0; |
| 388 | if (ui->mnemon2iCheckBox->isChecked()) addrMode |= I; |
| 389 | if (ui->mnemon2dCheckBox->isChecked()) addrMode |= D; |
| 390 | if (ui->mnemon2nCheckBox->isChecked()) addrMode |= N; |
| 391 | if (ui->mnemon2sCheckBox->isChecked()) addrMode |= S; |
| 392 | if (ui->mnemon2sfCheckBox->isChecked()) addrMode |= SF; |
| 393 | if (ui->mnemon2xCheckBox->isChecked()) addrMode |= X; |
| 394 | if (ui->mnemon2sxCheckBox->isChecked()) addrMode |= SX; |
| 395 | if (ui->mnemon2sxfCheckBox->isChecked()) addrMode |= SXF; |
| 396 | Pep::addrModesMap.insert(DECO, addrMode); |
| 397 | addrMode = 0; |
| 398 | if (ui->mnemon3iCheckBox->isChecked()) addrMode |= I; |
| 399 | if (ui->mnemon3dCheckBox->isChecked()) addrMode |= D; |
| 400 | if (ui->mnemon3nCheckBox->isChecked()) addrMode |= N; |
| 401 | if (ui->mnemon3sCheckBox->isChecked()) addrMode |= S; |
| 402 | if (ui->mnemon3sfCheckBox->isChecked()) addrMode |= SF; |
| 403 | if (ui->mnemon3xCheckBox->isChecked()) addrMode |= X; |
| 404 | if (ui->mnemon3sxCheckBox->isChecked()) addrMode |= SX; |
| 405 | if (ui->mnemon3sxfCheckBox->isChecked()) addrMode |= SXF; |
| 406 | Pep::addrModesMap.insert(STRO, addrMode); |
| 407 | } |