From eec16eea457ffd703b8f99fc7359943c994fd4c3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 10 Feb 2021 16:15:28 -0500 Subject: [PATCH] thumb32: Implement UXTB16 --- 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 5dfc7df9..dbc92aaa 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -201,7 +201,7 @@ INST(thumb32_UXTH, "UXTH", "11111010000111111111dd INST(thumb32_UXTAH, "UXTAH", "111110100001nnnn1111dddd10rrmmmm") INST(thumb32_SXTB16, "SXTB16", "11111010001011111111dddd10rrmmmm") INST(thumb32_SXTAB16, "SXTAB16", "111110100010nnnn1111dddd10rrmmmm") -//INST(thumb32_UXTB16, "UXTB16", "11111010001111111111----1-------") +INST(thumb32_UXTB16, "UXTB16", "11111010001111111111dddd10rrmmmm") //INST(thumb32_UXTAB16, "UXTAB16", "111110100011----1111----1-------") //INST(thumb32_SXTB, "SXTB", "11111010010011111111----1-------") //INST(thumb32_SXTAB, "SXTAB", "111110100100----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 0a76a8ce..48478ad9 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp @@ -65,6 +65,18 @@ bool ThumbTranslatorVisitor::thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rota return true; } +bool ThumbTranslatorVisitor::thumb32_UXTB16(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.And(rotated, ir.Imm32(0x00FF00FF)); + + ir.SetRegister(d, result); + return true; +} + bool ThumbTranslatorVisitor::thumb32_UXTH(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 c4503b43..ce205f98 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -126,6 +126,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_SXTAB16(Reg n, Reg d, SignExtendRotation rotate, Reg m); bool thumb32_SXTH(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rotate, Reg m); + bool thumb32_UXTB16(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);