diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 75342dcc9..af4602a33 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -1402,6 +1402,20 @@ void cmps(const InstructionT &instruction, AddressT &eCX, AddressT &eSI, Address repeat_ene(instruction, status, eCX, flow_controller); } +template +void scas(const InstructionT &instruction, AddressT &eCX, AddressT &eDI, IntT &eAX, MemoryT &memory, Status &status, FlowControllerT &flow_controller) { + if(repetition_over(instruction, eCX)) { + return; + } + + const IntT rhs = memory.template access(Source::ES, eDI); + eDI += status.direction() * sizeof(IntT); + + Primitive::sub(eAX, rhs, status); + + repeat_ene(instruction, status, eCX, flow_controller); +} + template void lods(const InstructionT &instruction, AddressT &eCX, AddressT &eSI, IntT &eAX, MemoryT &memory, Status &status, FlowControllerT &flow_controller) { if(repetition_over(instruction, eCX)) { @@ -1698,6 +1712,9 @@ template < case Operation::STOS: Primitive::stos(instruction, eCX(), eDI(), pair_low(), memory, status, flow_controller); break; + case Operation::SCAS: + Primitive::scas(instruction, eCX(), eDI(), pair_low(), memory, status, flow_controller); + break; } // Write to memory if required to complete this operation. diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 7176b479b..36c756e38 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -414,6 +414,9 @@ struct FailedExecution { // STOS @"AA.json.gz", @"AB.json.gz", + + // SCAS + @"AE.json.gz", @"AF.json.gz", /* @"E0.json.gz", // LOOPNE @"E1.json.gz", // LOOPE