aboutsummaryrefslogtreecommitdiff
path: root/qtmips_asm
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-22 00:06:49 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-22 00:06:49 +0200
commit5cf69aa5d7cab0079acec7b5ad7b70b96d01e801 (patch)
tree8351311d6f45db540a6bf57e05a3a42e771a851e /qtmips_asm
parent2b637518403bfbec4a6823dccc09a9301751302e (diff)
downloadqtmips-5cf69aa5d7cab0079acec7b5ad7b70b96d01e801.tar.gz
qtmips-5cf69aa5d7cab0079acec7b5ad7b70b96d01e801.tar.bz2
qtmips-5cf69aa5d7cab0079acec7b5ad7b70b96d01e801.zip
Implemented SKIP/SPACE assembler directives.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_asm')
-rw-r--r--qtmips_asm/simpleasm.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/qtmips_asm/simpleasm.cpp b/qtmips_asm/simpleasm.cpp
index e62ee00..0deea6f 100644
--- a/qtmips_asm/simpleasm.cpp
+++ b/qtmips_asm/simpleasm.cpp
@@ -266,6 +266,68 @@ bool SimpleAsm::process_line(QString line, QString filename,
address = value;
return true;
}
+ if ((op == ".SPACE") || (op == ".SKIP")) {
+ bool ok;
+ fixmatheval::FmeExpression expression;
+ fixmatheval::FmeValue value;
+ fixmatheval::FmeValue fill = 0;
+ if ((operands.count() != 1) && (operands.count() != 2)) {
+ error = ".space/.skip unexpected number of operands";
+ emit report_message(messagetype::MSG_ERROR, filename, line_number, 0, error, "");
+ error_occured = true;
+ if (error_ptr != nullptr)
+ *error_ptr = error;
+ return false;
+ }
+ if (operands.count() > 1) {
+ ok = expression.parse(operands.at(1), error);
+ if (!ok) {
+ fatal_occured = true;
+ error = tr(".space/.skip %1 parse error.").arg(line);
+ emit report_message(messagetype::MSG_ERROR, filename, line_number, 0, error, "");
+ error_occured = true;
+ if (error_ptr != nullptr)
+ *error_ptr = error;
+ return false;
+ }
+ ok = expression.eval(fill, symtab, error);
+ if (!ok) {
+ fatal_occured = true;
+ error = tr(".space/.skip %1 evaluation error.").arg(line);
+ emit report_message(messagetype::MSG_ERROR, filename, line_number, 0, error, "");
+ error_occured = true;
+ if (error_ptr != nullptr)
+ *error_ptr = error;
+ return false;
+ }
+ }
+ ok = expression.parse(operands.at(0), error);
+ if (!ok) {
+ fatal_occured = true;
+ error = tr(".space/.skip %1 parse error.").arg(line);
+ emit report_message(messagetype::MSG_ERROR, filename, line_number, 0, error, "");
+ error_occured = true;
+ if (error_ptr != nullptr)
+ *error_ptr = error;
+ return false;
+ }
+ ok = expression.eval(value, symtab, error);
+ if (!ok) {
+ fatal_occured = true;
+ error = tr(".space/.skip %1 evaluation error.").arg(line);
+ emit report_message(messagetype::MSG_ERROR, filename, line_number, 0, error, "");
+ error_occured = true;
+ if (error_ptr != nullptr)
+ *error_ptr = error;
+ return false;
+ }
+ while (value-- > 0) {
+ if (!fatal_occured)
+ mem->write_byte(address, (uint8_t)fill);
+ address += 1;
+ }
+ return true;
+ }
if ((op == ".EQU") || (op == ".SET")) {
if ((operands.count() > 2) || (operands.count() < 1)) {
error = tr(".set or .equ incorrect arguments number.");