From d35377c7763b7c2a0b415599f518210865d69c94 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 12 Oct 2023 15:52:05 -0400 Subject: [PATCH] Implement SALC, SETMO, SETMOC. --- .../Implementation/PerformImplementation.hpp | 34 +++++++++++++++++++ InstructionSets/x86/Status.hpp | 4 +-- OSBindings/Mac/Clock SignalTests/8088Tests.mm | 12 +++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 015091194..19bd32de3 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -890,6 +890,24 @@ inline void std(Status &status) { status.set_from(1); } inline void sti(Status &status) { status.set_from(1); } inline void cmc(Status &status) { status.set_from(!status.flag()); } +inline void salc(uint8_t &al, const Status &status) { + al = status.flag() ? 0xff : 0x00; +} + +template +void setmo(IntT &destination, Status &status) { + destination = ~0; + status.set_from(0); + status.set_from(destination); +} + +template +void setmoc(IntT &destination, uint8_t cl, Status &status) { + if(cl) { + setmo(destination, status); + } +} + } template < @@ -1051,6 +1069,22 @@ template < case Operation::CMC: Primitive::cmc(status); return; case Operation::XCHG: Primitive::xchg(destination(), source()); return; + + case Operation::SALC: Primitive::salc(registers.al(), status); return; + case Operation::SETMO: + if constexpr (model == Model::i8086) { + Primitive::setmo(destination(), status); + } else { + // TODO. + } + return; + case Operation::SETMOC: + if constexpr (model == Model::i8086) { + Primitive::setmoc(destination(), registers.cl(), status); + } else { + // TODO. + } + return; } // Write to memory if required to complete this operation. diff --git a/InstructionSets/x86/Status.hpp b/InstructionSets/x86/Status.hpp index f65042261..71efb2f8c 100644 --- a/InstructionSets/x86/Status.hpp +++ b/InstructionSets/x86/Status.hpp @@ -82,7 +82,7 @@ class Status { using FlagT = uint32_t; // Flag getters. - template bool flag() { + template bool flag() const { switch(flag) { case Flag::Carry: return carry; case Flag::AuxiliaryCarry: return auxiliary_carry; @@ -97,7 +97,7 @@ class Status { } // Condition evaluation. - template bool condition() { + template bool condition() const { switch(test) { case Condition::Overflow: return flag(); case Condition::Below: return flag(); diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 9cc725bbb..dd217b15a 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -377,13 +377,14 @@ struct FailedExecution { @"C5.json.gz", // LDS @"C4.json.gz", // LES -*/ @"8D.json.gz", // LEA +*/ // TODO: CMPS, LODS, MOVS, SCAS, STOS // TODO: LOOP, LOOPE, LOOPNE +/* // MOV @"88.json.gz", @"89.json.gz", @"8A.json.gz", @"8B.json.gz", @"8C.json.gz", @"8E.json.gz", @@ -394,7 +395,6 @@ struct FailedExecution { @"BC.json.gz", @"BD.json.gz", @"BE.json.gz", @"BF.json.gz", @"C6.json.gz", @"C7.json.gz", -/* // AND @"20.json.gz", @"21.json.gz", @"22.json.gz", @"23.json.gz", @"24.json.gz", @"25.json.gz", @"80.4.json.gz", @"81.4.json.gz", @"83.4.json.gz", @@ -443,8 +443,14 @@ struct FailedExecution { @"95.json.gz", @"96.json.gz", @"97.json.gz", // TODO: XLAT - // TODO: SALC, SETMO, SETMOC */ + @"D6.json.gz", // SALC + + // SETMO + @"D0.6.json.gz", @"D1.6.json.gz", + // SETMOC + @"D2.6.json.gz", @"D3.6.json.gz", + ]]; NSSet *ignoreList = nil;