From 28a201da162af4e28c298b1d565ebcb0d76ee5d2 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 18 Jul 2016 09:25:33 +0100 Subject: [PATCH] Implement Thumb ADR instruction --- src/frontend/decoder/thumb16.h | 4 ++-- src/frontend/disassembler/disassembler_thumb.cpp | 5 +++++ src/frontend/translate/translate_arm.cpp | 2 +- src/frontend/translate/translate_thumb.cpp | 11 ++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/frontend/decoder/thumb16.h b/src/frontend/decoder/thumb16.h index 25893785..9850a099 100644 --- a/src/frontend/decoder/thumb16.h +++ b/src/frontend/decoder/thumb16.h @@ -56,7 +56,7 @@ private: }; template -const std::array, 43> g_thumb16_instruction_table = { +const std::array, 44> g_thumb16_instruction_table = { #define INST(fn, name, bitstring) detail::detail::GetMatcher(name, bitstring) @@ -113,7 +113,7 @@ const std::array, 43> g_thumb16_instruction_table = { //INST(&V::thumb16_LDR_sp, "LDR (SP)", "10011dddvvvvvvvv"), // Generate relative address instruction - //INST(&V::thumb16_ADR, "ADR", "10100dddvvvvvvvv"), + INST(&V::thumb16_ADR, "ADR", "10100dddvvvvvvvv"), //INST(&V::thumb16_ADD_sp, "ADD (relative to SP)", "10101dddvvvvvvvv"), // Miscellaneous 16-bit instructions diff --git a/src/frontend/disassembler/disassembler_thumb.cpp b/src/frontend/disassembler/disassembler_thumb.cpp index ae796202..e40e5210 100644 --- a/src/frontend/disassembler/disassembler_thumb.cpp +++ b/src/frontend/disassembler/disassembler_thumb.cpp @@ -244,6 +244,11 @@ public: return Common::StringFromFormat("ldr %s, [%s, #%u]", RegStr(t), RegStr(n), imm32); } + std::string thumb16_ADR(Reg d, Imm8 imm8) { + u32 imm32 = imm8 << 2; + return Common::StringFromFormat("adr %s, +#%u", RegStr(d), imm32); + } + std::string thumb16_SXTH(Reg m, Reg d) { return Common::StringFromFormat("sxth %s, %s", RegStr(d), RegStr(m)); } diff --git a/src/frontend/translate/translate_arm.cpp b/src/frontend/translate/translate_arm.cpp index cfdfc8bc..d3ccc09c 100644 --- a/src/frontend/translate/translate_arm.cpp +++ b/src/frontend/translate/translate_arm.cpp @@ -9,7 +9,7 @@ #include "frontend/decoder/arm.h" #include "frontend/ir/ir.h" #include "frontend/ir/ir_emitter.h" -#include "translate.h" +#include "frontend/translate/translate.h" namespace Dynarmic { namespace Arm { diff --git a/src/frontend/translate/translate_thumb.cpp b/src/frontend/translate/translate_thumb.cpp index 47cd841a..fcbfc0e0 100644 --- a/src/frontend/translate/translate_thumb.cpp +++ b/src/frontend/translate/translate_thumb.cpp @@ -10,7 +10,7 @@ #include "frontend/arm_types.h" #include "frontend/decoder/thumb16.h" #include "frontend/ir/ir_emitter.h" -#include "translate.h" +#include "frontend/translate/translate.h" namespace Dynarmic { namespace Arm { @@ -440,6 +440,15 @@ struct ThumbTranslatorVisitor final { return true; } + bool thumb16_ADR(Reg d, Imm8 imm8) { + u32 imm32 = imm8 << 2; + // ADR ,