Feature: Add mov_rm32_r32 instruction & more expressive execution with CPU trace
This commit is contained in:
@@ -2,9 +2,32 @@
|
||||
|
||||
#include "ExecutorCases.h"
|
||||
#include "Instruction.h"
|
||||
#include "Bus.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace executor_cases {
|
||||
void Mov_r32_imm32(CPUContext& cc) {
|
||||
std::cout << "[Instruction] mov " << x86::Register2Str((x86::Register)cc.m_Instruction.m_Operand1) << ", " << std::hex << cc.m_Instruction.m_Operand2 << std::endl;
|
||||
cc.m_Registers[cc.m_Instruction.m_Operand1] = cc.m_Instruction.m_Operand2;
|
||||
}
|
||||
|
||||
void Mov_rm32_r32(CPUContext& cc) {
|
||||
x86::ModRM modrm = cc.m_Instruction.optional.m_ModRM;
|
||||
|
||||
std::cout << "[Instruction] ";
|
||||
|
||||
switch(modrm.m_State) {
|
||||
case x86::ModRMState::R:
|
||||
cc.m_Registers[modrm.m_Rm] = cc.m_Registers[modrm.m_Reg];
|
||||
std::cout << "mov " << x86::Register2Str((x86::Register)modrm.m_Rm) << ", " << x86::Register2Str((x86::Register)modrm.m_Rm);
|
||||
break;
|
||||
default:
|
||||
cc.m_Bus->WriteX<uint32_t>(helpers::ResolveModRMAddress(cc), cc.m_Registers[modrm.m_Reg]);
|
||||
std::cout << "mov DWORD PTR [0x" << helpers::ResolveModRMAddress(cc) << "], " << x86::Register2Str((x86::Register)modrm.m_Reg);
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user