public void SubtractDecimal(byte a, byte b, bool inputCarry, byte resultValue, bool negative, bool overflow, bool zeroed, bool resultCarry) { var result = ArithmeticHelpers.SubtractDecimal(a, b, inputCarry); result.Result.Should().Be(resultValue); result.Carried.Should().Be(resultCarry); result.Overflowed.Should().Be(overflow); result.Negative.Should().Be(negative); result.Zeroed.Should().Be(zeroed); }
public void Execute(State state) { var addressingMode = OpcodeMap[state.OpCode]; var(targetAddress, canSkipCycle) = addressingMode.GetAddress(state); var value = state.Memory[targetAddress]; state.ClockCycle += addressingMode.StandardCpuCycles - (canSkipCycle ? 1 : 0); var arithmeticResult = state.Status.DecimalMode ? ArithmeticHelpers.SubtractDecimal(state.Registers.A, value, state.Status.Carry) : ArithmeticHelpers.SubtractBinary(state.Registers.A, value, state.Status.Carry); state.Registers.A = arithmeticResult.Result; state.Status.Carry = arithmeticResult.Carried; state.Status.Overflow = arithmeticResult.Overflowed; state.Status.ZeroResult = arithmeticResult.Zeroed; state.Status.NegativeResult = arithmeticResult.Negative; }