diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 0b234690..37e6a6d4 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -192,7 +192,7 @@ INST(thumb32_BLX_imm, "BLX (imm)", "11110Svvvvvvvvvv11j0jv INST(thumb32_LSL_reg, "LSL (reg)", "111110100000mmmm1111dddd0000ssss") INST(thumb32_LSR_reg, "LSR (reg)", "111110100010mmmm1111dddd0000ssss") INST(thumb32_ASR_reg, "ASR (reg)", "111110100100mmmm1111dddd0000ssss") -//INST(thumb32_ROR_reg, "ROR (reg)", "11111010011-----1111----0000----") +INST(thumb32_ROR_reg, "ROR (reg)", "111110100110mmmm1111dddd0000ssss") INST(thumb32_SXTH, "SXTH", "11111010000011111111dddd10rrmmmm") INST(thumb32_SXTAH, "SXTAH", "111110100000nnnn1111dddd10rrmmmm") INST(thumb32_UXTH, "UXTH", "11111010000111111111dddd10rrmmmm") 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 1ef9b400..8d80565e 100644 --- a/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp +++ b/src/frontend/A32/translate/impl/thumb32_data_processing_register.cpp @@ -50,6 +50,19 @@ bool ThumbTranslatorVisitor::thumb32_LSR_reg(Reg m, Reg d, Reg s) { return true; } +bool ThumbTranslatorVisitor::thumb32_ROR_reg(Reg m, Reg d, Reg s) { + if (d == Reg::PC || m == Reg::PC || s == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto shift_s = ir.LeastSignificantByte(ir.GetRegister(s)); + const auto apsr_c = ir.GetCFlag(); + const auto result_carry = ir.RotateRight(ir.GetRegister(m), shift_s, apsr_c); + + ir.SetRegister(d, result_carry.result); + return true; +} + bool ThumbTranslatorVisitor::thumb32_SXTB(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 464926fc..88fe2563 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -185,6 +185,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_ASR_reg(Reg m, Reg d, Reg s); bool thumb32_LSL_reg(Reg m, Reg d, Reg s); bool thumb32_LSR_reg(Reg m, Reg d, Reg s); + bool thumb32_ROR_reg(Reg m, Reg d, Reg s); bool thumb32_SXTB(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_SXTB16(Reg d, SignExtendRotation rotate, Reg m); bool thumb32_SXTAB(Reg n, Reg d, SignExtendRotation rotate, Reg m);