From ebab7ede55271d0e779dd37255fdcad2f2f30357 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 3 May 2019 10:48:04 -0400 Subject: [PATCH] A32: Implement Thumb-1 variant of WFI --- src/frontend/A32/decoder/thumb16.h | 1 + src/frontend/A32/disassembler/disassembler_thumb.cpp | 4 ++++ src/frontend/A32/translate/translate_thumb.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/frontend/A32/decoder/thumb16.h b/src/frontend/A32/decoder/thumb16.h index 77bcd797..934e4c80 100644 --- a/src/frontend/A32/decoder/thumb16.h +++ b/src/frontend/A32/decoder/thumb16.h @@ -91,6 +91,7 @@ std::optional>> DecodeThumb16(u16 INST(&V::thumb16_NOP, "NOP", "1011111100000000"), // v6T2 INST(&V::thumb16_SEV, "SEV", "1011111101000000"), // v7 INST(&V::thumb16_WFE, "WFE", "1011111100100000"), // v7 + INST(&V::thumb16_WFI, "WFI", "1011111100110000"), // v7 // Miscellaneous 16-bit instructions INST(&V::thumb16_SXTH, "SXTH", "1011001000mmmddd"), // v6 diff --git a/src/frontend/A32/disassembler/disassembler_thumb.cpp b/src/frontend/A32/disassembler/disassembler_thumb.cpp index 6949b07e..12aa0238 100644 --- a/src/frontend/A32/disassembler/disassembler_thumb.cpp +++ b/src/frontend/A32/disassembler/disassembler_thumb.cpp @@ -258,6 +258,10 @@ public: return "wfe"; } + std::string thumb16_WFI() { + return "wfi"; + } + std::string thumb16_SXTH(Reg m, Reg d) { return fmt::format("sxth {}, {}", d, m); } diff --git a/src/frontend/A32/translate/translate_thumb.cpp b/src/frontend/A32/translate/translate_thumb.cpp index bb9ddc1e..bdefe327 100644 --- a/src/frontend/A32/translate/translate_thumb.cpp +++ b/src/frontend/A32/translate/translate_thumb.cpp @@ -689,6 +689,11 @@ struct ThumbTranslatorVisitor final { return RaiseException(Exception::WaitForEvent); } + // WFI + bool thumb16_WFI() { + return RaiseException(Exception::WaitForInterrupt); + } + // SXTH , // Rd cannot encode R15. bool thumb16_SXTH(Reg m, Reg d) {