Feature: Add mov_rm32_r32 instruction & more expressive execution with CPU trace
This commit is contained in:
@@ -20,6 +20,7 @@ constexpr std::array<ExecutorCase, 255> GenerateExecutorTable(){
|
||||
table[Opcode::NOP] = executor_cases::Nop;
|
||||
table[Opcode::HLT] = executor_cases::Hlt;
|
||||
table[Opcode::MOV_R32_IMM32] = executor_cases::Mov_r32_imm32;
|
||||
table[Opcode::MOV_RM32_R32] = executor_cases::Mov_rm32_r32;
|
||||
table[Opcode::ADD_RM32_R32] = executor_cases::Add_rm32_r32;
|
||||
return table;
|
||||
}
|
||||
@@ -29,3 +30,33 @@ static constexpr std::array<ExecutorCase, 255> s_ExecutorTable = GenerateExecuto
|
||||
const std::array<ExecutorCase, 255>& GetExecutorTable() {
|
||||
return s_ExecutorTable;
|
||||
}
|
||||
|
||||
namespace executor_cases::helpers {
|
||||
|
||||
uint32_t ResolveModRMAddress(CPUContext& cc) {
|
||||
x86::ModRM modrm = cc.m_Instruction.optional.m_ModRM;
|
||||
uint32_t value = 0;
|
||||
|
||||
switch(modrm.m_State) {
|
||||
case x86::ModRMState::LR_DISP32:
|
||||
case x86::ModRMState::LR_DISP8:
|
||||
value = cc.m_Registers[modrm.m_Rm] + cc.m_Instruction.m_Operand1;
|
||||
break;
|
||||
case x86::ModRMState::DISP32:
|
||||
value = cc.m_Instruction.m_Operand1;
|
||||
break;
|
||||
case x86::ModRMState::LR:
|
||||
value = cc.m_Registers[modrm.m_Rm];
|
||||
break;
|
||||
case x86::ModRMState::R:
|
||||
std::cout << "x86::ModRM reached x86::ModRMState::R during ResolveModRMAddress()" << std::endl;
|
||||
std::cout << "This behavior is unexpected." << std::endl;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Undefined MODRM state encountered!");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user