protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { var sum = (ushort) (arg + cpuState.A); if (cpuState.IsFlagSet(CpuState.Flags.Carry)) { ++sum; } var byteSum = (byte)(sum & 0xFF); cpuState.SetOverflow(cpuState.A, arg, byteSum); cpuState.A = byteSum; cpuState.SetZeroFlag(cpuState.A); cpuState.SetNegativeFlag(cpuState.A); cpuState.SetFlag(CpuState.Flags.Carry, sum & 0xFF00); }
protected override void InternalExecute(CpuState cpuState, IMemory memory, byte arg, Action<byte> write, ref int cycles) { // A - M - C -> A N Z C I D V // + + + - - + int a = cpuState.A; arg ^= 0xFF; a += arg; if (cpuState.IsFlagSet(CpuState.Flags.Carry)) { ++a; } var byteResult = (byte) (a & 0xFF); cpuState.SetOverflow(cpuState.A, arg, byteResult); cpuState.A = byteResult; cpuState.SetNegativeFlag(cpuState.A); cpuState.SetZeroFlag(cpuState.A); cpuState.SetFlag(CpuState.Flags.Carry, (byteResult & 0x80) == 0); }