diff --git a/InstructionSets/x86/Implementation/PerformImplementation.hpp b/InstructionSets/x86/Implementation/PerformImplementation.hpp index d80b9a749..db223d9f2 100644 --- a/InstructionSets/x86/Implementation/PerformImplementation.hpp +++ b/InstructionSets/x86/Implementation/PerformImplementation.hpp @@ -400,34 +400,15 @@ inline void das(uint8_t &al, Status &status) { status.zero = status.parity = al; } -template -void adc(IntT &destination, IntT source, Status &status) { - /* - DEST ← DEST + SRC + CF; - */ - /* - The OF, SF, ZF, AF, CF, and PF flags are set according to the result. - */ - const IntT result = destination + source + status.carry_bit(); - - status.carry = Numeric::carried_out() - 1>(destination, source, result); - status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result); - status.sign = result & top_bit(); - status.zero = status.parity = result; - status.overflow = overflow(destination, source, result); - - destination = result; -} - -template +template void add(IntT &destination, IntT source, Status &status) { /* - DEST ← DEST + SRC; + DEST ← DEST + SRC [+ CF]; */ /* The OF, SF, ZF, AF, CF, and PF flags are set according to the result. */ - const IntT result = destination + source; + const IntT result = destination + source + (with_carry ? status.carry_bit() : 0); status.carry = Numeric::carried_out() - 1>(destination, source, result); status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result); @@ -438,34 +419,15 @@ void add(IntT &destination, IntT source, Status &status) { destination = result; } -template -void sbb(IntT &destination, IntT source, Status &status) { - /* - DEST ← DEST - (SRC + CF); - */ - /* - The OF, SF, ZF, AF, CF, and PF flags are set according to the result. - */ - const IntT result = destination - source - status.carry_bit(); - - status.carry = Numeric::carried_out() - 1>(destination, source, result); - status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result); - status.sign = result & top_bit(); - status.zero = status.parity = result; - status.overflow = overflow(destination, source, result); - - destination = result; -} - -template +template void sub(IntT &destination, IntT source, Status &status) { /* - DEST ← DEST - SRC; + DEST ← DEST - (SRC [+ CF]); */ /* The OF, SF, ZF, AF, CF, and PF flags are set according to the result. */ - const IntT result = destination - source; + const IntT result = destination - source - (with_borrow ? status.carry_bit() : 0); status.carry = Numeric::carried_out() - 1>(destination, source, result); status.auxiliary_carry = Numeric::carried_in<4>(destination, source, result); @@ -971,12 +933,12 @@ 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::CMP: Primitive::sub(destination(), source(), status); break; - case Operation::TEST: Primitive::test(destination(), source(), status); break; + case Operation::ADC: Primitive::add(destination(), source(), status); break; + case Operation::ADD: Primitive::add(destination(), source(), status); break; + case Operation::SBB: Primitive::sub(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 630c3f76e..dc9b27823 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -297,7 +297,7 @@ struct FailedExecution { @"DC.json.gz", @"DD.json.gz", @"DE.json.gz", @"DE.json.gz", // Untested: HLT, WAIT - +*/ // ADC @"10.json.gz", @"11.json.gz", @"12.json.gz", @"13.json.gz", @"14.json.gz", @"15.json.gz", @"80.2.json.gz", @"81.2.json.gz", @"83.2.json.gz", @@ -313,7 +313,7 @@ struct FailedExecution { // SUB @"28.json.gz", @"29.json.gz", @"2A.json.gz", @"2B.json.gz", @"2C.json.gz", @"2D.json.gz", @"80.5.json.gz", @"81.5.json.gz", @"83.5.json.gz", - +/* // MUL @"F6.4.json.gz", @"F7.4.json.gz", @@ -413,9 +413,9 @@ 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", @@ -423,9 +423,9 @@ struct FailedExecution { // @"F6.0.json.gz", @"F7.0.json.gz", // XCHG - @"86.json.gz", @"87.json.gz", - @"91.json.gz", @"92.json.gz", @"93.json.gz", @"94.json.gz", - @"95.json.gz", @"96.json.gz", @"97.json.gz", +// @"86.json.gz", @"87.json.gz", +// @"91.json.gz", @"92.json.gz", @"93.json.gz", @"94.json.gz", +// @"95.json.gz", @"96.json.gz", @"97.json.gz", // TODO: XLAT // TODO: SALC, SETMO, SETMOC