From e12ee8d4d78632294af621a10acda12ff5a0ad4a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 10 Feb 2021 16:07:17 -0500 Subject: [PATCH] thumb32: Implement UXTH --- src/frontend/A32/decoder/thumb32.inc | 2 +- .../impl/thumb32_data_processing_register.cpp | 12 ++++++++++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 12e0e4e2..da51e73e 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -197,7 +197,7 @@ //INST(thumb32_ROR_reg, "ROR (reg)", "11111010011-----1111----0000----") INST(thumb32_SXTH, "SXTH", "11111010000011111111dddd10rrmmmm") INST(thumb32_SXTAH, "SXTAH", "111110100000nnnn1111dddd10rrmmmm") -//INST(thumb32_UXTH, "UXTH", "11111010000111111111----1-------") +INST(thumb32_UXTH, "UXTH", "11111010000111111111dddd10rrmmmm") //INST(thumb32_UXTAH, "UXTAH", "111110100001----1111----1-------") //INST(thumb32_SXTB16, "SXTB16", "11111010001011111111----1-------") //INST(thumb32_SXTAB16, "SXTAB16", "111110100010----1111----1-------") diff --git a/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp b/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp index 7d2e9252..fe61f1b3 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp @@ -36,4 +36,16 @@ bool ThumbTranslatorVisitor::thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rota return true; } +bool ThumbTranslatorVisitor::thumb32_UXTH(Reg d, SignExtendRotation rotate, Reg m) { + if (d == Reg::PC || m == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto rotated = Rotate(ir, m, rotate); + const auto result = ir.ZeroExtendHalfToWord(ir.LeastSignificantHalf(rotated)); + + ir.SetRegister(d, result); + 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 bbd238eb..d1571ecf 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -124,6 +124,7 @@ struct ThumbTranslatorVisitor final { // thumb32 data processing (register) instructions bool thumb32_SXTH(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rotate, Reg m); + bool thumb32_UXTH(Reg d, SignExtendRotation rotate, Reg m); // thumb32 long multiply, long multiply accumulate, and divide instructions bool thumb32_SDIV(Reg n, Reg d, Reg m);