// INR Increment Register or Memory // If register C contains 99H, the instruction: INR C will cause register C to contain 9AH private int INR(IByteOperandStrategy op) { var in8 = op.Read(this); var out8 = (byte)(in8 + 1); Flags = Flags .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_AC(in8, 1)) .calc_SZP(out8); op.Write(this, out8); return(op == OpMem ? 10 : 5); }
// ADI Add Immediate To Accumulator // The byte of immediate data is added to the contents of the accumulator using two's complement arithmetic. private int ADI(byte b) { var out16 = Accumulator + b; Flags = Flags .Set(FlagIndex.Carry, ((out16 & 0xFF00) != 0)).Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_AC(Accumulator, b)) .calc_SZP((byte)out16); Accumulator = (byte)out16; return(7); }
// ADD Register or Memory To Accumulator private int ADD(IByteOperandStrategy operand) { var in8 = operand.Read(this); var out16 = Accumulator + in8; Flags = Flags .Set(FlagIndex.Carry, ((out16 & 0xFF00) != 0)).Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_AC(Accumulator, in8)) .calc_SZP((byte)out16); Accumulator = (byte)out16; return(operand == OpMem ? 7 : 4); }