From 34a8f6603505a9c6575665f7d93ecc177df99144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A0rius=20Mont=C3=B3n?= Date: Sun, 4 Jul 2021 22:46:41 +0200 Subject: [PATCH] Simplified extension check --- src/Instruction.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Instruction.cpp b/src/Instruction.cpp index 78f2b36..dbe019e 100644 --- a/src/Instruction.cpp +++ b/src/Instruction.cpp @@ -13,22 +13,19 @@ Instruction::Instruction(uint32_t instr) { } extension_t Instruction::check_extension() const { - if (((m_instr & 0x0000007F) == 0b0110011) + if (((m_instr & 0x0000007F) == 0b0110011) && ( ((m_instr & 0x7F000000) >> 25) == 0b0000001)) { return M_EXTENSION; } else if ((m_instr & 0x0000007F) == 0b0101111) { - return A_EXTENSION; - } else if ((m_instr & 0x00000003) == 0b11) { + return A_EXTENSION; + } else if ((m_instr & 0x00000003) == 0b00) { + return C_EXTENSION; + } else if ((m_instr & 0x00000003) == 0b01) { + return C_EXTENSION; + } else if ((m_instr & 0x00000003) == 0b10) { + return C_EXTENSION; + } else { return BASE_EXTENSION; - } else if ((m_instr & 0x00000003) == 0b00) { - return C_EXTENSION; - } else if ((m_instr & 0x00000003) == 0b01) { - return C_EXTENSION; - } else if ((m_instr & 0x00000003) == 0b10) { - return C_EXTENSION; - } else { - std::cout << "Unknown\n"; - return UNKNOWN_EXTENSION; } }