From e61dc0466f2f0dd475e52edfb8b53d4ad3c33338 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 10 Nov 2023 22:22:32 -0500 Subject: [PATCH] Add callout for tracking segment register changes. --- .../x86/Implementation/PerformImplementation.hpp | 4 ++-- OSBindings/Mac/Clock SignalTests/8088Tests.mm | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 26b42b168..a12bd65ae 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -256,7 +256,7 @@ template < case Operation::MOV: Primitive::mov(destination_w(), source_r()); if constexpr (std::is_same_v) { - context.registers.did_update(instruction.destination.source()); + context.registers.did_update(instruction.destination().source()); } break; @@ -327,7 +327,7 @@ template < case Operation::POP: destination_w() = Primitive::pop(context); if constexpr (std::is_same_v) { - context.registers.did_update(instruction.destination.source()); + context.registers.did_update(instruction.destination().source()); } break; case Operation::PUSH: diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 0bd7a64c6..0efed5e3b 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -249,15 +249,13 @@ struct Memory { } uint32_t segment_base(InstructionSet::x86::Source segment) { - uint32_t physical_address; using Source = InstructionSet::x86::Source; switch(segment) { - default: physical_address = registers_.ds_; break; - case Source::ES: physical_address = registers_.es_; break; - case Source::CS: physical_address = registers_.cs_; break; - case Source::SS: physical_address = registers_.ss_; break; + default: return registers_.ds_base_; + case Source::ES: return registers_.es_base_; + case Source::CS: return registers_.cs_base_; + case Source::SS: return registers_.ss_base_; } - return physical_address << 4; } uint32_t address(InstructionSet::x86::Source segment, uint16_t offset) { @@ -556,6 +554,11 @@ struct FailedExecution { registers.ss_ = [value[@"ss"] intValue]; registers.ip_ = [value[@"ip"] intValue]; + registers.did_update(Registers::Source::ES); + registers.did_update(Registers::Source::CS); + registers.did_update(Registers::Source::DS); + registers.did_update(Registers::Source::SS); + const uint16_t flags_value = [value[@"flags"] intValue]; flags.set(flags_value);