From c764a2b8892d7a864757ae3ab75f8a145f54956f Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 21 Dec 2016 22:44:14 +0000 Subject: [PATCH] Implement MUL (T1) --- src/frontend/decoder/thumb16.h | 2 +- src/frontend/disassembler/disassembler_thumb.cpp | 4 ++++ src/frontend/translate/translate_thumb.cpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/frontend/decoder/thumb16.h b/src/frontend/decoder/thumb16.h index 24335da9..3cb98d56 100644 --- a/src/frontend/decoder/thumb16.h +++ b/src/frontend/decoder/thumb16.h @@ -53,7 +53,7 @@ boost::optional&> DecodeThumb16(u16 instruction) { INST(&V::thumb16_CMP_reg_t1, "CMP (reg, T1)", "0100001010mmmnnn"), INST(&V::thumb16_CMN_reg, "CMN (reg)", "0100001011mmmnnn"), INST(&V::thumb16_ORR_reg, "ORR (reg)", "0100001100mmmddd"), - //INST(&V::thumb16_MULS_rr, "MULS (rr)", "0100001101mmmddd"), + INST(&V::thumb16_MUL_reg, "MUL (reg)", "0100001101nnnddd"), INST(&V::thumb16_BIC_reg, "BIC (reg)", "0100001110mmmddd"), INST(&V::thumb16_MVN_reg, "MVN (reg)", "0100001111mmmddd"), diff --git a/src/frontend/disassembler/disassembler_thumb.cpp b/src/frontend/disassembler/disassembler_thumb.cpp index 16b3938c..2ed91671 100644 --- a/src/frontend/disassembler/disassembler_thumb.cpp +++ b/src/frontend/disassembler/disassembler_thumb.cpp @@ -120,6 +120,10 @@ public: return fmt::format("orrs {}, {}", d_n, m); } + std::string thumb16_MUL_reg(Reg n, Reg d_m) { + return fmt::format("muls {}, {}, {}", d_m, n, d_m); + } + std::string thumb16_BIC_reg(Reg m, Reg d_n) { return fmt::format("bics {}, {}", d_n, m); } diff --git a/src/frontend/translate/translate_thumb.cpp b/src/frontend/translate/translate_thumb.cpp index c79b745d..8aece474 100644 --- a/src/frontend/translate/translate_thumb.cpp +++ b/src/frontend/translate/translate_thumb.cpp @@ -328,6 +328,17 @@ struct ThumbTranslatorVisitor final { return true; } + bool thumb16_MUL_reg(Reg n, Reg d_m) { + Reg d = d_m, m = d_m; + // MULS , , + // Rd cannot encode R15. + auto result = ir.Mul(ir.GetRegister(m), ir.GetRegister(n)); + ir.SetRegister(d, result); + ir.SetNFlag(ir.MostSignificantBit(result)); + ir.SetZFlag(ir.IsZero(result)); + return true; + } + bool thumb16_BIC_reg(Reg m, Reg d_n) { Reg d = d_n, n = d_n; // BICS ,