aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-06 13:08:28 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-03-06 13:08:28 +0100
commit74be8fa660f58a646298dc4cdb2280e4c457a574 (patch)
tree4ca784599280248ead72976644112f75f9ea791e
parente91fb27de2cad7408039b4155d68fe5441a22219 (diff)
downloadqtmips-74be8fa660f58a646298dc4cdb2280e4c457a574.tar.gz
qtmips-74be8fa660f58a646298dc4cdb2280e4c457a574.tar.bz2
qtmips-74be8fa660f58a646298dc4cdb2280e4c457a574.zip
Correct parsing of register + offset operands, i.e., LW and SW.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_machine/instruction.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/qtmips_machine/instruction.cpp b/qtmips_machine/instruction.cpp
index 73246ac..42b70d7 100644
--- a/qtmips_machine/instruction.cpp
+++ b/qtmips_machine/instruction.cpp
@@ -1017,17 +1017,19 @@ void instruction_from_string_build_base(const InstructionMap *im = nullptr,
static int parse_reg_from_string(QString str, uint *chars_taken = nullptr)
{
int res;
+ uint ctk;
if (str.count() < 2 || str.at(0) != '$')
return -1;
const char *p = str.toLatin1().data() + 1;
char *r;
res = std::strtol(p, &r, 0);
+ ctk = r - p + 1;
if (p == r)
return -1;
if (res > 31)
return -1;
if (chars_taken != nullptr)
- *chars_taken = r - p;
+ *chars_taken = ctk;
return res;
}
@@ -1122,6 +1124,7 @@ Instruction Instruction::from_string(QString str, bool *pok, uint32_t inst_addr)
field = -1;
break;
}
+ fl = fl.mid(1);
continue;
}
uint bits = IMF_SUB_GET_BITS(adesc->loc);