From 2aa33db8be7397d39080e6ec96a9158e0c1e63e5 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 2 Jul 2019 18:53:21 +0200 Subject: Simple highlighter for assembly language added. Signed-off-by: Pavel Pisa --- qtmips_machine/instruction.cpp | 14 ++++++++++++++ qtmips_machine/instruction.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'qtmips_machine') diff --git a/qtmips_machine/instruction.cpp b/qtmips_machine/instruction.cpp index 502fa81..6792aa6 100644 --- a/qtmips_machine/instruction.cpp +++ b/qtmips_machine/instruction.cpp @@ -1073,6 +1073,9 @@ ssize_t Instruction::code_from_string(std::uint32_t *code, size_t buffsize, std::uint32_t inst_addr, RelocExpressionList *reloc, int line, bool pseudo_opt, int options) { + if (str_to_instruction_code_map.isEmpty()) + instruction_from_string_build_base(); + int field = 0; std::uint32_t inst_code = 0; auto i = str_to_instruction_code_map.lowerBound(inst_base); @@ -1321,3 +1324,14 @@ bool Instruction::update(std::int64_t val, RelocExpression *relocexp) { dt |= (val << relocexp->lsb_bit) & mask; return true; } + +void Instruction::append_recognized_instructions(QStringList &list) { + if (str_to_instruction_code_map.isEmpty()) + instruction_from_string_build_base(); + + foreach (const QString &str, str_to_instruction_code_map.keys()) + list.append(str); + list.append("LA"); + list.append("LI"); + list.append("NOP"); +} diff --git a/qtmips_machine/instruction.h b/qtmips_machine/instruction.h index 76fca87..101d82f 100644 --- a/qtmips_machine/instruction.h +++ b/qtmips_machine/instruction.h @@ -38,6 +38,7 @@ #include #include +#include #include #include "machinedefs.h" @@ -159,6 +160,8 @@ public: int line = 0, bool pseudo_opt = false, int options = 0); bool update(std::int64_t val, RelocExpression *relocexp); + + static void append_recognized_instructions(QStringList &list); private: std::uint32_t dt; }; -- cgit v1.2.3