From 74be8fa660f58a646298dc4cdb2280e4c457a574 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 6 Mar 2019 13:08:28 +0100 Subject: Correct parsing of register + offset operands, i.e., LW and SW. Signed-off-by: Pavel Pisa --- qtmips_machine/instruction.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qtmips_machine/instruction.cpp') 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); -- cgit v1.2.3