From 967f3cf7e12005ca63979ac7e1b497de71205330 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 21 Dec 2016 22:44:27 +0000 Subject: [PATCH] Implement CPS (Thumb) * Since currently only User mode is emulated, CPS is a NOP. --- src/frontend/decoder/thumb16.h | 2 +- src/frontend/disassembler/disassembler_thumb.cpp | 4 ++++ src/frontend/translate/translate_thumb.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/frontend/decoder/thumb16.h b/src/frontend/decoder/thumb16.h index 3cb98d56..a857d93d 100644 --- a/src/frontend/decoder/thumb16.h +++ b/src/frontend/decoder/thumb16.h @@ -95,7 +95,7 @@ boost::optional&> DecodeThumb16(u16 instruction) { INST(&V::thumb16_PUSH, "PUSH", "1011010Mxxxxxxxx"), // v4T INST(&V::thumb16_POP, "POP", "1011110Pxxxxxxxx"), // v4T INST(&V::thumb16_SETEND, "SETEND", "101101100101x000"), // v6 - //INST(&V::thumb16_CPS, "CPS", "10110110011m0aif"), // v6 + INST(&V::thumb16_CPS, "CPS", "10110110011m0aif"), // v6 INST(&V::thumb16_REV, "REV", "1011101000mmmddd"), // v6 INST(&V::thumb16_REV16, "REV16", "1011101001mmmddd"), // v6 INST(&V::thumb16_REVSH, "REVSH", "1011101011mmmddd"), // v6 diff --git a/src/frontend/disassembler/disassembler_thumb.cpp b/src/frontend/disassembler/disassembler_thumb.cpp index 2ed91671..149605f0 100644 --- a/src/frontend/disassembler/disassembler_thumb.cpp +++ b/src/frontend/disassembler/disassembler_thumb.cpp @@ -274,6 +274,10 @@ public: return fmt::format("setend {}", E ? "BE" : "LE"); } + std::string thumb16_CPS(bool im, bool a, bool i, bool f) { + return fmt::format("cps{} {}{}{}", im ? "id" : "ie", a ? "a" : "", i ? "i" : "", f ? "f" : ""); + } + std::string thumb16_REV(Reg m, Reg d) { return fmt::format("rev {}, {}", d, m); } diff --git a/src/frontend/translate/translate_thumb.cpp b/src/frontend/translate/translate_thumb.cpp index 8aece474..367c7b08 100644 --- a/src/frontend/translate/translate_thumb.cpp +++ b/src/frontend/translate/translate_thumb.cpp @@ -699,6 +699,12 @@ struct ThumbTranslatorVisitor final { return false; } + bool thumb16_CPS(bool, bool, bool, bool) { + // CPS{IE,ID} + // A CPS is treated as a NOP in User mode. + return true; + } + bool thumb16_REV(Reg m, Reg d) { // REV , // Rd cannot encode R15.