コード例 #1
0
        // CPI Compare Immediate With Accumulator
        // The byte of immediate data is compared to the contents of the accumulator.
        private int CPI(byte b)
        {
            var cmp16 = Accumulator - b;

            Flags = Flags
                    .Set(FlagIndex.Carry, ((cmp16 & 0x00FF) >= Accumulator && b != 0))
                    .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_subAC(Accumulator, b))
                    .calc_SZP((byte)cmp16);

            return(7);
        }
コード例 #2
0
        // Compare
        private int CMP(IByteOperandStrategy operand)
        {
            var cmp16 = Accumulator - operand.Read(this);

            Flags = Flags
                    .Set(FlagIndex.Carry, ((cmp16 & 0x00FF) >= Accumulator && operand.Read(this) != 0))
                    .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_subAC(Accumulator, operand.Read(this)))
                    .calc_SZP((byte)cmp16);

            return(operand == OpMem ? 7 : 4);
        }
コード例 #3
0
        // DCR Decrement Register or Memory
        // The specified register or memory byte is decremented by one.
        // If the H register contains 3AH, the L register contains 7CH, and memory location 3A7CH contains 40H,
        // the instruction: OCR M
        // will cause memory location 3A7CH to contain 3FH.
        private int DCR(IByteOperandStrategy op)
        {
            var in8  = op.Read(this);
            var out8 = (byte)(in8 - 1);

            Flags = Flags
                    .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_subAC(in8, 1))
                    .calc_SZP(out8);

            op.Write(this, out8);
            return(op == OpMem ? 10 : 5);
        }
コード例 #4
0
        //SUI Subtract Immediate From Accumulator
        // The byte of immediate data is subtracted from the contents of the accumulator using two's complement arithmetic.
        private int SUI(byte b)
        {
            var out16 = (ushort)(Accumulator - b);

            Flags = Flags
                    .Set(FlagIndex.Carry, ((out16 & 0x00FF) >= Accumulator && b != 0))
                    .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_subAC(Accumulator, b))
                    .calc_SZP((byte)out16);

            Accumulator = (byte)out16;

            return(7);
        }
コード例 #5
0
        // SUB Subtract Register or Memory From Accumulator
        private int SUB(IByteOperandStrategy operand)
        {
            var in8   = operand.Read(this);
            var out16 = Accumulator - in8;

            Flags = Flags
                    .Set(FlagIndex.Carry, ((out16 & 0x00FF) >= Accumulator && in8 != 0))
                    .Set(FlagIndex.AuxCarry, AuxCarryPredicates.calc_subAC(Accumulator, in8))
                    .calc_SZP((byte)out16);

            Accumulator = (byte)out16;
            return(operand == OpMem ? 7 : 4);
        }