diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-07-02 15:00:17 +0200 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-07-02 15:00:17 +0200 |
commit | dce00ea47fd4100df97349fd2bf998169b05b74a (patch) | |
tree | c493de54f5f0309b5af893e4b9e8fa8c34cdf9a6 /qtmips_gui | |
parent | cf97513e757cdd25e6b1dd1fd584e4ec13d93cb1 (diff) | |
download | qtmips-dce00ea47fd4100df97349fd2bf998169b05b74a.tar.gz qtmips-dce00ea47fd4100df97349fd2bf998169b05b74a.tar.bz2 qtmips-dce00ea47fd4100df97349fd2bf998169b05b74a.zip |
Change instruction parsing to allow multiple words pseudo-operations.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | qtmips_gui/programmodel.cpp | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index c9d89d9..3301367 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -606,16 +606,21 @@ void MainWindow::compile_source() { } if (line.isEmpty()) continue; - machine::Instruction inst; - inst = machine::Instruction::from_string(line, &ok, address, &reloc, ln); - if (!ok) { + std::uint32_t inst[2] = {0, 0}; + ssize_t size = machine::Instruction::code_from_string(inst, 8, line, + address, &reloc, ln, true); + if (size < 0) { QMessageBox::critical(this, "QtMips Error", tr("line %1 instruction %2 parse error.") .arg(QString::number(ln), line)); + ok = false; break; } - mem->write_word(address, inst.data()); - address += 4; + std::uint32_t *p = inst; + for (ssize_t l = 0; l < size; l += 4) { + mem->write_word(address, *(p++)); + address += 4; + } } SymbolTableDb symtab(machine->symbol_table()); foreach(machine::RelocExpression *r, reloc) { diff --git a/qtmips_gui/programmodel.cpp b/qtmips_gui/programmodel.cpp index 64dffb8..0f3341f 100644 --- a/qtmips_gui/programmodel.cpp +++ b/qtmips_gui/programmodel.cpp @@ -274,8 +274,7 @@ bool ProgramModel::setData(const QModelIndex & index, const QVariant & value, in mem->write_word(address, data); break; case 3: - data = machine::Instruction::from_string(value.toString(), &ok, address).data(); - if (!ok) + if (machine::Instruction::code_from_string(&data, 4, value.toString(), address) < 0) return false; mem->write_word(address, data); break; |