diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1126ad42..d921a63f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -152,6 +152,7 @@ if ("A32" IN_LIST DYNARMIC_FRONTENDS) frontend/A32/translate/impl/thumb16.cpp frontend/A32/translate/impl/thumb32.cpp frontend/A32/translate/impl/thumb32_misc.cpp + frontend/A32/translate/impl/thumb32_multiply.cpp frontend/A32/translate/impl/thumb32_parallel.cpp frontend/A32/translate/impl/translate_arm.h frontend/A32/translate/impl/translate_thumb.h diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index d4d52c53..eb80cb53 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -261,7 +261,7 @@ INST(thumb32_SEL, "SEL", "111110101010nnnn1111dd INST(thumb32_CLZ, "CLZ", "111110101011nnnn1111dddd1000mmmm") // Multiply, Multiply Accumulate, and Absolute Difference -//INST(thumb32_MUL, "MUL", "111110110000----1111----0000----") +INST(thumb32_MUL, "MUL", "111110110000nnnn1111dddd0000mmmm") //INST(thumb32_MLA, "MLA", "111110110000------------0000----") //INST(thumb32_MLS, "MLS", "111110110000------------0001----") //INST(thumb32_SMULXY, "SMULXY", "111110110001----1111----00------") diff --git a/src/frontend/A32/translate/impl/thumb32_multiply.cpp b/src/frontend/A32/translate/impl/thumb32_multiply.cpp new file mode 100644 index 00000000..53371d9d --- /dev/null +++ b/src/frontend/A32/translate/impl/thumb32_multiply.cpp @@ -0,0 +1,23 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2021 MerryMage + * SPDX-License-Identifier: 0BSD + */ + +#include "frontend/A32/translate/impl/translate_thumb.h" + +namespace Dynarmic::A32 { + +bool ThumbTranslatorVisitor::thumb32_MUL(Reg n, Reg d, Reg m) { + if (d == Reg::PC || n == Reg::PC || m == Reg::PC) { + return UnpredictableInstruction(); + } + + const auto reg_m = ir.GetRegister(m); + const auto reg_n = ir.GetRegister(n); + const auto result = ir.Mul(reg_n, reg_m); + + 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 1c140dd0..43f87722 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -128,6 +128,9 @@ struct ThumbTranslatorVisitor final { bool thumb32_REVSH(Reg n, Reg d, Reg m); bool thumb32_SEL(Reg n, Reg d, Reg m); + // thumb32 multiply instructions + bool thumb32_MUL(Reg n, Reg d, Reg m); + // thumb32 parallel add/sub instructions bool thumb32_SADD8(Reg n, Reg d, Reg m); bool thumb32_SADD16(Reg n, Reg d, Reg m);