From e0d6b60270288b4c8b3a655505e176d988d167a7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 10 Feb 2021 16:23:54 -0500 Subject: [PATCH] thumb32: Implement UXTAB --- src/frontend/A32/decoder/thumb32.inc | 2 +- .../impl/thumb32_data_processing_register.cpp | 13 +++++++++++++ src/frontend/A32/translate/impl/translate_thumb.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index d1a3c019..e03e2712 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -206,7 +206,7 @@ INST(thumb32_UXTAB16, "UXTAB16", "111110100011nnnn1111dd INST(thumb32_SXTB, "SXTB", "11111010010011111111dddd10rrmmmm") INST(thumb32_SXTAB, "SXTAB", "111110100100nnnn1111dddd10rrmmmm") INST(thumb32_UXTB, "UXTB", "11111010010111111111dddd10rrmmmm") -//INST(thumb32_UXTAB, "UXTAB", "111110100101----1111----1-------") +INST(thumb32_UXTAB, "UXTAB", "111110100101nnnn1111dddd10rrmmmm") // Parallel Addition and Subtraction (signed) INST(thumb32_SADD16, "SADD16", "111110101001nnnn1111dddd0000mmmm") 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 2eb4cfaf..cf6bbf7b 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp @@ -114,6 +114,19 @@ bool ThumbTranslatorVisitor::thumb32_UXTB16(Reg d, SignExtendRotation rotate, Re return true; } +bool ThumbTranslatorVisitor::thumb32_UXTAB(Reg n, Reg d, SignExtendRotation rotate, Reg m) { + if (d == Reg::PC || m == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto rotated = Rotate(ir, m, rotate); + const auto reg_n = ir.GetRegister(n); + const auto result = ir.Add(reg_n, ir.ZeroExtendByteToWord(ir.LeastSignificantByte(rotated))); + + ir.SetRegister(d, result); + return true; +} + bool ThumbTranslatorVisitor::thumb32_UXTAB16(Reg n, Reg d, SignExtendRotation rotate, Reg m) { if (d == Reg::PC || m == Reg::PC) { return UnpredictableInstruction(); diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index 5a4b5f4a..ceb54407 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -130,6 +130,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rotate, Reg m); bool thumb32_UXTB(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_UXTB16(Reg d, SignExtendRotation rotate, Reg m); + bool thumb32_UXTAB(Reg n, Reg d, SignExtendRotation rotate, Reg m); bool thumb32_UXTAB16(Reg n, Reg d, SignExtendRotation rotate, Reg m); bool thumb32_UXTH(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_UXTAH(Reg n, Reg d, SignExtendRotation rotate, Reg m);