From d2d996e6ba566dece538e471cae1de11ecc9e2c7 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 6 Mar 2021 19:19:46 +0000 Subject: [PATCH] thumb32: Implement EOR (reg) --- src/frontend/A32/decoder/thumb32.inc | 2 +- ...humb32_data_processing_shifted_register.cpp | 18 ++++++++++++++++++ .../A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 35c07f39..6ba27249 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -37,7 +37,7 @@ INST(thumb32_ORR_reg, "ORR (reg)", "11101010010Snnnn0vvvdd INST(thumb32_MVN_reg, "MVN (reg)", "11101010011S11110vvvddddvvttmmmm") INST(thumb32_ORN_reg, "ORN (reg)", "11101010011Snnnn0vvvddddvvttmmmm") INST(thumb32_TEQ_reg, "TEQ (reg)", "111010101001nnnn0vvv1111vvttmmmm") -//INST(thumb32_EOR_reg, "EOR (reg)", "11101010100---------------------") +INST(thumb32_EOR_reg, "EOR (reg)", "11101010100Snnnn0vvvddddvvttmmmm") //INST(thumb32_PKH, "PKH", "11101010110---------------------") //INST(thumb32_CMN_reg, "CMN (reg)", "111010110001--------1111--------") //INST(thumb32_ADD_reg, "ADD (reg)", "11101011000---------------------") diff --git a/src/frontend/A32/translate/impl/thumb32_data_processing_shifted_register.cpp b/src/frontend/A32/translate/impl/thumb32_data_processing_shifted_register.cpp index 1ed5b620..c9090100 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_shifted_register.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_shifted_register.cpp @@ -137,4 +137,22 @@ bool ThumbTranslatorVisitor::thumb32_TEQ_reg(Reg n, Imm<3> imm3, Imm<2> imm2, Sh return true; } +bool ThumbTranslatorVisitor::thumb32_EOR_reg(bool S, Reg n, Imm<3> imm3, Reg d, Imm<2> imm2, ShiftType type, Reg m) { + ASSERT_MSG(!(d == Reg::PC && S), "Decode error"); + + if ((d == Reg::PC && !S) || n == Reg::PC || m == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto shifted = EmitImmShift(ir.GetRegister(m), type, imm3, imm2, ir.GetCFlag()); + const auto result = ir.Eor(ir.GetRegister(n), shifted.result); + ir.SetRegister(d, result); + if (S) { + ir.SetNFlag(ir.MostSignificantBit(result)); + ir.SetZFlag(ir.IsZero(result)); + ir.SetCFlag(shifted.carry); + } + 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 d45ec8f0..2acf6e65 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -180,6 +180,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_MVN_reg(bool S, Imm<3> imm3, Reg d, Imm<2> imm2, ShiftType type, Reg m); bool thumb32_ORN_reg(bool S, Reg n, Imm<3> imm3, Reg d, Imm<2> imm2, ShiftType type, Reg m); bool thumb32_TEQ_reg(Reg n, Imm<3> imm3, Imm<2> imm2, ShiftType type, Reg m); + bool thumb32_EOR_reg(bool S, Reg n, Imm<3> imm3, Reg d, Imm<2> imm2, ShiftType type, Reg m); // thumb32 data processing (modified immediate) instructions bool thumb32_TST_imm(Imm<1> i, Reg n, Imm<3> imm3, Imm<8> imm8);