From f0f14fa5e8d9ec8adc3a1925d99093a94f2cd135 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 10 Jul 2016 13:10:06 +0800 Subject: [PATCH] Implement thumb1_MOV_reg --- src/frontend/decoder/thumb1.h | 4 ++-- src/frontend/disassembler_thumb.cpp | 5 +++++ src/frontend/translate_thumb.cpp | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/frontend/decoder/thumb1.h b/src/frontend/decoder/thumb1.h index d9867699..da8ceb78 100644 --- a/src/frontend/decoder/thumb1.h +++ b/src/frontend/decoder/thumb1.h @@ -56,7 +56,7 @@ private: }; template -static const std::array, 29> g_thumb1_instruction_table {{ +static const std::array, 30> g_thumb1_instruction_table {{ #define INST(fn, name, bitstring) detail::detail::GetMatcher(name, bitstring) @@ -94,7 +94,7 @@ static const std::array, 29> g_thumb1_instruction_table {{ // Special data instructions { INST(&V::thumb1_ADD_reg_t2, "ADD (reg, T2)", "01000100Dmmmmddd") }, // v4T, Low regs: v6T2 { INST(&V::thumb1_CMP_reg_t2, "CMP (reg, T2)", "01000101Nmmmmnnn") }, // v4T - //{ INST(&V::thumb1_MOV_high, "MOV (high)", "01000110dmmmmddd") }, // v4T, Low regs: v6 + { INST(&V::thumb1_MOV_reg, "MOV (reg)", "01000110Dmmmmddd") }, // v4T, Low regs: v6 // Store/Load single data item instructions //{ INST(&V::thumb1_LDR_lit, "LDR (literal)", "01001dddvvvvvvvv") }, diff --git a/src/frontend/disassembler_thumb.cpp b/src/frontend/disassembler_thumb.cpp index 4b079238..1d705867 100644 --- a/src/frontend/disassembler_thumb.cpp +++ b/src/frontend/disassembler_thumb.cpp @@ -217,6 +217,11 @@ public: return Common::StringFromFormat("cmp %s, %s", RegStr(n), RegStr(m)); } + std::string thumb1_MOV_reg(bool d_hi, Reg m, Reg d_lo) { + Reg d = d_hi ? (d_lo + 8) : d_lo; + return Common::StringFromFormat("mov %s, %s", RegStr(d), RegStr(m)); + } + std::string thumb1_UDF() { return Common::StringFromFormat("udf"); } diff --git a/src/frontend/translate_thumb.cpp b/src/frontend/translate_thumb.cpp index 797777e9..2dd513e2 100644 --- a/src/frontend/translate_thumb.cpp +++ b/src/frontend/translate_thumb.cpp @@ -351,6 +351,19 @@ struct TranslatorVisitor final { ir.SetVFlag(result.overflow); return true; } + bool thumb1_MOV_reg(bool d_hi, Reg m, Reg d_lo) { + Reg d = d_hi ? (d_lo + 8) : d_lo; + // MOV , + auto result = ir.GetRegister(m); + if (d == Reg::PC) { + ir.ALUWritePC(result); + ir.SetTerm(IR::Term::ReturnToDispatch{}); + return false; + } else { + ir.SetRegister(d, result); + return true; + } + } bool thumb1_UDF() { return TranslateThisInstruction();