diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index 00701a33..62d83ef3 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -274,7 +274,7 @@ INST(thumb32_SMUSD, "SMUSD", "111110110100nnnn1111dd //INST(thumb32_SMLSD, "SMLSD", "111110110100------------000-----") INST(thumb32_SMMUL, "SMMUL", "111110110101nnnn1111dddd000Rmmmm") INST(thumb32_SMMLA, "SMMLA", "111110110101nnnnaaaadddd000Rmmmm") -//INST(thumb32_SMMLS, "SMMLS", "111110110110------------000-----") +INST(thumb32_SMMLS, "SMMLS", "111110110110nnnnaaaadddd000Rmmmm") INST(thumb32_USAD8, "USAD8", "111110110111nnnn1111dddd0000mmmm") INST(thumb32_USADA8, "USADA8", "111110110111nnnnaaaadddd0000mmmm") diff --git a/src/frontend/A32/translate/impl/thumb32_multiply.cpp b/src/frontend/A32/translate/impl/thumb32_multiply.cpp index 7d5f4e52..fd7e32ef 100644 --- a/src/frontend/A32/translate/impl/thumb32_multiply.cpp +++ b/src/frontend/A32/translate/impl/thumb32_multiply.cpp @@ -86,6 +86,25 @@ bool ThumbTranslatorVisitor::thumb32_SMMLA(Reg n, Reg a, Reg d, bool R, Reg m) { return true; } +bool ThumbTranslatorVisitor::thumb32_SMMLS(Reg n, Reg a, Reg d, bool R, Reg m) { + if (d == Reg::PC || n == Reg::PC || m == Reg::PC || a == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto n64 = ir.SignExtendWordToLong(ir.GetRegister(n)); + const auto m64 = ir.SignExtendWordToLong(ir.GetRegister(m)); + const auto a64 = ir.Pack2x32To1x64(ir.Imm32(0), ir.GetRegister(a)); + const auto temp = ir.Sub(a64, ir.Mul(n64, m64)); + const auto result_carry = ir.MostSignificantWord(temp); + auto result = result_carry.result; + if (R) { + result = ir.AddWithCarry(result, ir.Imm32(0), result_carry.carry).result; + } + + ir.SetRegister(d, result); + return true; +} + bool ThumbTranslatorVisitor::thumb32_SMMUL(Reg n, Reg d, bool R, Reg m) { if (d == Reg::PC || n == 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 13d4be39..c8092ffd 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -134,6 +134,7 @@ struct ThumbTranslatorVisitor final { bool thumb32_MUL(Reg n, Reg d, Reg m); bool thumb32_SMLAXY(Reg n, Reg a, Reg d, bool N, bool M, Reg m); bool thumb32_SMMLA(Reg n, Reg a, Reg d, bool R, Reg m); + bool thumb32_SMMLS(Reg n, Reg a, Reg d, bool R, Reg m); bool thumb32_SMMUL(Reg n, Reg d, bool R, Reg m); bool thumb32_SMUAD(Reg n, Reg d, bool M, Reg m); bool thumb32_SMUSD(Reg n, Reg d, bool M, Reg m);