From 92b4d0b54662b814897ef68559fdc51ebaa295c0 Mon Sep 17 00:00:00 2001 From: 0x221E Date: Wed, 4 Feb 2026 22:48:20 +0100 Subject: [PATCH] Patch: ADD_RM32_R32 support LR_DISP32, LR_DISP8 --- src/Bus.h | 2 ++ src/ExecutorCases.cpp | 3 ++- src/main.cpp | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Bus.h b/src/Bus.h index d6912b9..5e5489c 100644 --- a/src/Bus.h +++ b/src/Bus.h @@ -17,6 +17,8 @@ public: { static_assert(std::is_unsigned_v, "T must be an unsigned int of any size smaller than 8 bytes!"); + std::cout << "Bus write: " << std::hex << address << std::endl; + switch(address) { case 0x00008000 ... 0x000FFFFF: diff --git a/src/ExecutorCases.cpp b/src/ExecutorCases.cpp index d1446c4..1338584 100644 --- a/src/ExecutorCases.cpp +++ b/src/ExecutorCases.cpp @@ -43,8 +43,9 @@ namespace executor_cases { break; } case x86::ModRMState::LR_DISP8: + case x86::ModRMState::LR_DISP32: { - uint32_t dstAddress = cc.m_Registers[modrm.m_Rm] + cc.m_Instruction.m_Operand2; + uint32_t dstAddress = cc.m_Registers[modrm.m_Rm] + cc.m_Instruction.m_Operand1; uint32_t dstPrevValue = cc.m_Bus->AccessX(dstAddress); uint32_t currRegValue = cc.m_Registers[modrm.m_Reg]; uint32_t result = dstPrevValue + currRegValue; diff --git a/src/main.cpp b/src/main.cpp index cdc32ff..90d8341 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,18 +3,18 @@ #include "Metal.h" // mov eax, 0xF4 -// mov ecx, 0x800c -// add [ecx], eax +// mov ecx, 0x8000 +// add [ecx + 0x0010], eax uint8_t test[] = { 0xB8, 0xF4, 0x00, 0x00, 0x00, - 0xB9, 0x0c, 0x80, 0x00, 0x00, - 0x01, 0x01, + 0xB9, 0x00, 0x80, 0x00, 0x00, + 0x01, 0x81, 0x10, 0x00, 0x00, 0x00, 0x00, }; int main(int argc, char** argv) { Metal metal; - metal.Upload2Memory(test, 13); + metal.Upload2Memory(test, 17); metal.Run(); return 0; }