aboutsummaryrefslogtreecommitdiff
path: root/qtmips_asm
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-26 00:44:43 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-26 00:44:43 +0200
commit679ffb09d45bc86d8fb98439f7488924070fc7e8 (patch)
tree364fd6acb41f2eef708e598695e8f051d5c43535 /qtmips_asm
parent6c09f661b83dd13a8403243c1441efa5c4900538 (diff)
downloadqtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.tar.gz
qtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.tar.bz2
qtmips-679ffb09d45bc86d8fb98439f7488924070fc7e8.zip
Add #pragma processing to integrated assembler and its usage to control windows.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_asm')
-rw-r--r--qtmips_asm/simpleasm.cpp22
-rw-r--r--qtmips_asm/simpleasm.h4
2 files changed, 24 insertions, 2 deletions
diff --git a/qtmips_asm/simpleasm.cpp b/qtmips_asm/simpleasm.cpp
index 223b34d..8695624 100644
--- a/qtmips_asm/simpleasm.cpp
+++ b/qtmips_asm/simpleasm.cpp
@@ -114,6 +114,7 @@ bool SimpleAsm::process_line(QString line, QString filename,
bool maybe_label = true;
bool final = false;
bool separator;
+ bool space_separated = false;
int token_beg = -1;
int token_last = -1;
int operand_num = -1;
@@ -129,6 +130,11 @@ bool SimpleAsm::process_line(QString line, QString filename,
if (line.mid(pos).startsWith("#include")) {
if ((line.count() > pos + 8) && !line.at(pos + 8).isSpace())
final = true;
+ } else if (line.mid(pos).startsWith("#pragma")) {
+ if ((line.count() > pos + 7) && !line.at(pos + 7).isSpace())
+ final = true;
+ else
+ space_separated = true;
} else {
final = true;
}
@@ -140,7 +146,9 @@ bool SimpleAsm::process_line(QString line, QString filename,
if (line.at(pos + 1) == '/')
final = true;
}
- separator = final || (maybe_label && (ch == ':')) || ((operand_num >= 0) && (ch == ','));
+ separator = final || (maybe_label && (ch == ':')) ||
+ ((operand_num >= 0) && ((ch == ',') ||
+ (space_separated && ch.isSpace() && (token_beg != -1))));
if (maybe_label && (ch == ':')) {
maybe_label = false;
if (token_beg == -1) {
@@ -235,6 +243,9 @@ bool SimpleAsm::process_line(QString line, QString filename,
return true;
}
+ if (op == "#PRAGMA") {
+ return process_pragma(operands, filename, line_number, error_ptr);
+ }
if (op == "#INCLUDE") {
bool res = true;
QString incname;
@@ -633,3 +644,12 @@ bool SimpleAsm::finish(QString *error_ptr) {
return !error_occured;
}
+
+bool SimpleAsm::process_pragma(QStringList &operands, QString filename,
+ int line_number, QString *error_ptr) {
+ (void)operands;
+ (void)filename;
+ (void)line_number;
+ (void)error_ptr;
+ return true;
+}
diff --git a/qtmips_asm/simpleasm.h b/qtmips_asm/simpleasm.h
index ac06ca1..8f74577 100644
--- a/qtmips_asm/simpleasm.h
+++ b/qtmips_asm/simpleasm.h
@@ -74,11 +74,13 @@ public:
virtual bool process_file(QString filename, QString *error_ptr = nullptr);
bool finish(QString *error_ptr = nullptr);
protected:
+ virtual bool process_pragma(QStringList &operands, QString filename = "",
+ int line_number = 0, QString *error_ptr = nullptr);
bool error_occured;
bool fatal_occured;
+ SymbolTableDb *symtab;
private:
QStringList include_stack;
- SymbolTableDb *symtab;
machine::MemoryAccess *mem;
machine::RelocExpressionList reloc;
std::uint32_t address;