From 5602db88f431b6d2e3c5a4498e4bd0077bfc4b88 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Feb 2021 23:48:58 -0500 Subject: [PATCH] thumb32: Implement MOVW --- src/frontend/A32/decoder/thumb32.inc | 2 +- ...thumb32_data_processing_plain_binary_immediate.cpp | 11 +++++++++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 9ab4135b..3d7cad5c 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -73,7 +73,7 @@ INST(thumb32_EOR_imm, "EOR (imm)", "11110v00100Snnnn0vvvdd // Data Processing (Plain Binary Immediate) //INST(thumb32_ADR, "ADR", "11110-10000011110---------------") //INST(thumb32_ADD_imm_2, "ADD (imm)", "11110-100000----0---------------") -//INST(thumb32_MOVW_imm, "MOVW (imm)", "11110-100100----0---------------") +INST(thumb32_MOVW_imm, "MOVW (imm)", "11110i100100iiii0iiiddddiiiiiiii") //INST(thumb32_ADR, "ADR", "11110-10101011110---------------") //INST(thumb32_SUB_imm_2, "SUB (imm)", "11110-101010----0---------------") INST(thumb32_MOVT, "MOVT", "11110i101100iiii0iiiddddiiiiiiii") diff --git a/src/frontend/A32/translate/impl/thumb32_data_processing_plain_binary_immediate.cpp b/src/frontend/A32/translate/impl/thumb32_data_processing_plain_binary_immediate.cpp index 09c847cc..8244ddc2 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_plain_binary_immediate.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_plain_binary_immediate.cpp @@ -20,4 +20,15 @@ bool ThumbTranslatorVisitor::thumb32_MOVT(Imm<1> imm1, Imm<4> imm4, Imm<3> imm3, return true; } +bool ThumbTranslatorVisitor::thumb32_MOVW_imm(Imm<1> imm1, Imm<4> imm4, Imm<3> imm3, Reg d, Imm<8> imm8) { + if (d == Reg::PC) { + return UnpredictableInstruction(); + } + + const IR::U32 imm = ir.Imm32(concatenate(imm4, imm1, imm3, imm8).ZeroExtend()); + + ir.SetRegister(d, imm); + return true; +} + } // namespace Dynarmic::A32 diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index 782e0706..1012fa5b 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -161,6 +161,7 @@ struct ThumbTranslatorVisitor final { // thumb32 data processing (plain binary immediate) instructions. bool thumb32_MOVT(Imm<1> imm1, Imm<4> imm4, Imm<3> imm3, Reg d, Imm<8> imm8); + bool thumb32_MOVW_imm(Imm<1> imm1, Imm<4> imm4, Imm<3> imm3, Reg d, Imm<8> imm8); // thumb32 miscellaneous control instructions bool thumb32_UDF();