From 08867f497019c39974e214f7e9450f3d828c1522 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 Oct 2023 22:15:33 -0400 Subject: [PATCH] Implement CMP. --- .../Implementation/PerformImplementation.hpp | 17 +++++++++++------ OSBindings/Mac/Clock SignalTests/8088Tests.mm | 15 ++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 55f5582b5..8cedf3767 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -455,7 +455,7 @@ void sbb(IntT &destination, IntT source, Status &status) { destination = result; } -template +template void sub(IntT &destination, IntT source, Status &status) { /* DEST ← DEST - SRC; @@ -471,7 +471,9 @@ void sub(IntT &destination, IntT source, Status &status) { status.zero = status.parity = result; status.overflow = overflow(destination, source, result); - destination = result; + if constexpr (write_back) { + destination = result; + } } template @@ -931,10 +933,13 @@ template < case Operation::HLT: flow_controller.halt(); return; case Operation::WAIT: flow_controller.wait(); return; - case Operation::ADC: Primitive::adc(destination(), source(), status); break; - case Operation::ADD: Primitive::add(destination(), source(), status); break; - case Operation::SBB: Primitive::sbb(destination(), source(), status); break; - case Operation::SUB: Primitive::sub(destination(), source(), status); break; + case Operation::ADC: Primitive::adc(destination(), source(), status); break; + case Operation::ADD: Primitive::add(destination(), source(), status); break; + case Operation::SBB: Primitive::sbb(destination(), source(), status); break; + case Operation::SUB: Primitive::sub(destination(), source(), status); break; + case Operation::CMP: Primitive::sub(destination(), source(), status); break; + + // TODO: all the below could call a common registers getter? case Operation::MUL: if constexpr (data_size == DataSize::Byte) { Primitive::mul(registers.ah(), registers.al(), source(), status); diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index a14a11adb..095bb4dbf 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -390,11 +390,11 @@ struct FailedExecution { @"80.6.json.gz", @"81.6.json.gz", @"83.6.json.gz", */ - // NEG - @"F6.3.json.gz", @"F7.3.json.gz", - - // NOT - @"F6.2.json.gz", @"F7.2.json.gz", +// // NEG +// @"F6.3.json.gz", @"F7.3.json.gz", +// +// // NOT +// @"F6.2.json.gz", @"F7.2.json.gz", /* // NOP @@ -412,6 +412,11 @@ struct FailedExecution { @"F5.json.gz", // CMC */ + // CMP + @"38.json.gz", @"39.json.gz", @"3A.json.gz", + @"3B.json.gz", @"3C.json.gz", @"3D.json.gz", + @"80.7.json.gz", @"81.7.json.gz", @"83.7.json.gz", + // TODO: CMP, TEST // TODO: XCHG, XLAT // TODO: SALC, SETMO, SETMOC