diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index 8cedf3767..93a1ab80f 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -476,6 +476,32 @@ void sub(IntT &destination, IntT source, Status &status) { } } +template +void test(IntT &destination, IntT source, Status &status) { + /* + TEMP ← SRC1 AND SRC2; + SF ← MSB(TEMP); + IF TEMP = 0 + THEN ZF ← 0; + ELSE ZF ← 1; + FI: + PF ← BitwiseXNOR(TEMP[0:7]); + CF ← 0; + OF ← 0; + */ + /* + The OF and CF flags are cleared to 0. + The SF, ZF, and PF flags are set according to the result (see the “Operation” section above). + The state of the AF flag is undefined. + */ + const IntT result = destination & source; + + status.sign = result & top_bit(); + status.zero = result; + status.carry = status.overflow = 0; + status.parity = result; +} + template void mul(IntT &destination_high, IntT &destination_low, IntT source, Status &status) { /* @@ -938,6 +964,7 @@ template < 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; + case Operation::TEST: Primitive::test(destination(), source(), status); break; // TODO: all the below could call a common registers getter? case Operation::MUL: diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 095bb4dbf..8fe9cb536 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -413,11 +413,15 @@ struct FailedExecution { */ // 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", +// @"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", + + // TEST + @"84.json.gz", @"85.json.gz", + @"A8.json.gz", @"A9.json.gz", + @"F6.0.json.gz", @"F7.0.json.gz", - // TODO: CMP, TEST // TODO: XCHG, XLAT // TODO: SALC, SETMO, SETMOC