Simplified extension check

This commit is contained in:
Màrius Montón 2021-07-04 22:46:41 +02:00
parent 5f47a8a906
commit 34a8f66035
1 changed files with 9 additions and 12 deletions

View File

@ -13,22 +13,19 @@ Instruction::Instruction(uint32_t instr) {
} }
extension_t Instruction::check_extension() const { extension_t Instruction::check_extension() const {
if (((m_instr & 0x0000007F) == 0b0110011) if (((m_instr & 0x0000007F) == 0b0110011)
&& ( ((m_instr & 0x7F000000) >> 25) == 0b0000001)) { && ( ((m_instr & 0x7F000000) >> 25) == 0b0000001)) {
return M_EXTENSION; return M_EXTENSION;
} else if ((m_instr & 0x0000007F) == 0b0101111) { } else if ((m_instr & 0x0000007F) == 0b0101111) {
return A_EXTENSION; return A_EXTENSION;
} else if ((m_instr & 0x00000003) == 0b11) { } 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; 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;
} }
} }