aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 15:29:50 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-07-03 15:29:50 +0200
commitea607bef4c1bce675bdcad145b20000bd67a1ac7 (patch)
treef03dee665dc89dded1489e58284f9a3de3802afe /qtmips_gui
parent194bbe845b479217b82fe738740cb5485499e739 (diff)
downloadqtmips-ea607bef4c1bce675bdcad145b20000bd67a1ac7.tar.gz
qtmips-ea607bef4c1bce675bdcad145b20000bd67a1ac7.tar.bz2
qtmips-ea607bef4c1bce675bdcad145b20000bd67a1ac7.zip
Process .equ and .set directives and ignore some others.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp55
1 files changed, 51 insertions, 4 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 46352ea..b40bbfc 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -619,6 +619,7 @@ void MainWindow::close_source() {
if (idx >= 0)
central_window->removeTab(idx);
delete editor;
+ update_open_file_list();
}
class SymbolTableDb : public fixmatheval::FmeSymbolDb {
@@ -701,8 +702,22 @@ void MainWindow::compile_source() {
}
if (line.isEmpty())
continue;
- QString op = line.split(" ").at(0).toUpper();
- if ((op == ".DATA") || (op == ".CODE")) {
+ int k = 0, l;
+ while (k < line.count()) {
+ if (!line.at(k).isSpace())
+ break;
+ k++;
+ }
+ l = k;
+ while (l < line.count()) {
+ if (!line.at(l).isLetterOrNumber() && !(line.at(l) == '.'))
+ break;
+ l++;
+ }
+ QString op = line.mid(k, l - k).toUpper();
+ if ((op == ".DATA") || (op == ".TEXT") ||
+ (op == ".GLOBL") || (op == ".END") ||
+ (op == ".ENT")) {
continue;
}
if (op == ".ORG") {
@@ -723,6 +738,38 @@ void MainWindow::compile_source() {
address = value;
continue;
}
+ if ((op == ".EQU") || (op == ".SET")) {
+ QStringList operands = line.mid(op.size()).split(",");
+ if ((operands.count() > 2) || (operands.count() < 1)) {
+ error_line = ln;
+ editor->setCursorToLine(error_line);
+ QMessageBox::critical(this, "QtMips Error",
+ tr("line %1 .set or .equ incorrect arguments number.")
+ .arg(QString::number(ln)));
+ break;
+ }
+ QString name = operands.at(0).trimmed();
+ if ((name == "noat") || (name == "noreored"))
+ continue;
+ bool ok;
+ fixmatheval::FmeValue value = 1;
+ if (operands.count() > 1) {
+ fixmatheval::FmeExpression expression;
+ ok = expression.parse(operands.at(1), error);
+ if (ok)
+ ok = expression.eval(value, &symtab, error);
+ if (!ok) {
+ error_line = ln;
+ editor->setCursorToLine(error_line);
+ QMessageBox::critical(this, "QtMips Error",
+ tr("line %1 .set or .equ %2 parse error.")
+ .arg(QString::number(ln), operands.at(1)));
+ break;
+ }
+ }
+ machine->set_symbol(name, value, 0);
+ continue;
+ }
if (op == ".WORD") {
foreach (QString s, line.mid(op.size()).split(",")) {
s = s.simplified();
@@ -788,8 +835,8 @@ void MainWindow::compile_source() {
error_line = r->line;
editor->setCursorToLine(error_line);
QMessageBox::critical(this, "QtMips Error",
- tr("instruction update error %1 at line %2, expression %3.")
- .arg(error, QString::number(r->line), expression.dump()));
+ tr("instruction update error %1 at line %2, expression %3 -> value %4.")
+ .arg(error, QString::number(r->line), expression.dump(), QString::number(value)));
}
}
mem->write_word(r->location, inst.data());