示例#1
0
        private void _sbc_hl_ss(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("SBC", "HL, {0}", register);
            }

            TStates += 15;

            if (FCarry)
            {
                source.Word++;
            }

            ushort result = (ushort)(HL.Word - source.Word);

            FSign      = StaticHelpers.TestBit(result, 15);
            FZero      = result == 0;
            FHalfCarry = StaticHelpers.TestHalfCarry(HL.Word, source.Word, result);
            FPV        = StaticHelpers.TestSubtractionOverflow(HL.Word, source.Word, result);
            FNegative  = true;
            FCarry     = (uint)(HL.Word - source.Word) > 0xFFFF;

            HL.Word = result;
        }
示例#2
0
 public byte this[RegisterPair index]
 {
     get
     {
         return this[index.Word];
     }
     set
     {
         this[index.Word] = value;
     }
 }
示例#3
0
 public byte this[RegisterPair index]
 {
     get
     {
         return(this[index.Word]);
     }
     set
     {
         this[index.Word] = value;
     }
 }
示例#4
0
        //
        private void _dec_ss(ref RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("DEC", "{0}", register);
            }

            TStates += 6;

            source.Word--;
        }
示例#5
0
        private void _inc_ss(ref RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("INC", "{0}", register);
            }

            TStates += 6;

            source.Word++;
        }
示例#6
0
        private void _pop_qq(ref RegisterPair destination, string register)
        {
            if (DebugMode)
            {
                DebugOut("POP", "{0}", register);
            }

            TStates += 10;

            destination.LoByte = Memory[SP.Word++];
            destination.HiByte = Memory[SP.Word++];
        }
示例#7
0
        private void _push_qq(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("PUSH", "{0}", register);
            }

            TStates += 11;

            SP.Word--;
            Memory[SP.Word] = source.HiByte;
            SP.Word--;
            Memory[SP.Word] = source.LoByte;
        }
示例#8
0
        private void _ex_de_hl()
        {
            if (DebugMode)
            {
                DebugOut("EX", "DE, HL");
            }

            TStates += 4;

            RegisterPair tmp = DE;

            DE = HL;
            HL = tmp;
        }
示例#9
0
        private void _ld_dd_addr(ref RegisterPair destination, string register)
        {
            int addr = Memory[PC.Word++] + (Memory[PC.Word++] << 8);

            if (DebugMode)
            {
                DebugOut("LD", "{0}, (#0x{1:X4})", register, addr);
            }

            TStates += 20;

            destination.LoByte = Memory[addr];
            destination.HiByte = Memory[addr + 1];
        }
示例#10
0
        private void _ld_addr_dd(RegisterPair source, string register)
        {
            int addr = Memory[PC.Word++] + (Memory[PC.Word++] << 8);

            if (DebugMode)
            {
                DebugOut("LD", "(#0x{0:X4}), {1}", addr, register);
            }

            TStates += 20;

            Memory[addr]     = source.LoByte;
            Memory[addr + 1] = source.HiByte;
        }
示例#11
0
        private void _ex_af_af_()
        {
            if (DebugMode)
            {
                DebugOut("EX", "AF, AF'");
            }

            TStates += 4;

            RegisterPair tmp = AF;

            AF  = AF_;
            AF_ = tmp;
        }
示例#12
0
        private void _ld_addr_dd(RegisterPair source, string register)
        {
            int addr = Memory[PC.Word++] + (Memory[PC.Word++] << 8);

            if (DebugMode)
            {
                DebugOut("LD", "(#0x{0:X4}), {1}", addr, register);

            }

            TStates += 20;

            Memory[addr] = source.LoByte;
            Memory[addr + 1] = source.HiByte;
        }
示例#13
0
        private void _ld_dd_nn(ref RegisterPair destination, string register)
        {
            byte loByte = Memory[PC.Word++];
            byte hiByte = Memory[PC.Word++];

            if (DebugMode)
            {
                DebugOut("LD", "{0}, #0x{1:X4}", register, loByte + (hiByte << 8));
            }

            TStates += 10;

            destination.HiByte = hiByte;
            destination.LoByte = loByte;
        }
示例#14
0
        private void _add_iy_pp(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("ADD", "IY, {0}", register);
            }

            TStates += 15;

            FHalfCarry = StaticHelpers.TestHalfCarry(IY.Word, source.Word, (ushort)(IY.Word + source.Word));
            FNegative  = false;
            FCarry     = (IY.Word + source.Word > 0xFFFF);

            IY.Word += source.Word;
        }
示例#15
0
        private void _add_iy_pp(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("ADD", "IY, {0}", register);
            }

            TStates += 15;

            FHalfCarry = StaticHelpers.TestHalfCarry(IY.Word, source.Word, (ushort)(IY.Word + source.Word));
            FNegative = false;
            FCarry = (IY.Word + source.Word > 0xFFFF);

            IY.Word += source.Word;
        }
示例#16
0
        private void _ld_dd_addr(ref RegisterPair destination, string register)
        {
            int addr = Memory[PC.Word++] + (Memory[PC.Word++] << 8);

            if (DebugMode)
            {
                DebugOut("LD", "{0}, (#0x{1:X4})", register, addr);

            }

            TStates += 20;

            destination.LoByte = Memory[addr];
            destination.HiByte = Memory[addr + 1];
        }
示例#17
0
        private void _add_hl_ss(RegisterPair source, string register, bool carry)
        {
            if (DebugMode)
            {
                if (carry)
                {
                    DebugOut("ADC", "HL, {0}", register);
                }
                else
                {
                    DebugOut("ADD", "HL, {0}", register);
                }
            }

            TStates += 11;

            if (carry && FCarry)
            {
                source.Word++;
            }

            ushort result = (ushort)(HL.Word + source.Word);

            if (carry)
            {
                FSign     = StaticHelpers.TestBit(result, 15);
                FZero     = result == 0;
                FNegative = false;
                FPV       = StaticHelpers.TestAdditionOverflow(HL.Word, source.Word, result);
            }

            FHalfCarry = StaticHelpers.TestHalfCarry(HL.Word, source.Word, result);
            FNegative  = false;
            FCarry     = (HL.Word + source.Word) > 0xFFFF;

            HL.Word = result;
        }
示例#18
0
        private void _add_hl_ss(RegisterPair source, string register, bool carry)
        {
            if (DebugMode)
            {
                if (carry)
                {
                    DebugOut("ADC", "HL, {0}", register);
                }
                else
                {
                    DebugOut("ADD", "HL, {0}", register);
                }
            }

            TStates += 11;

            if (carry && FCarry)
            {
                source.Word++;
            }

            ushort result = (ushort)(HL.Word + source.Word);

            if (carry)
            {
                FSign = StaticHelpers.TestBit(result, 15);
                FZero = result == 0;
                FNegative = false;
                FPV = StaticHelpers.TestAdditionOverflow(HL.Word, source.Word, result);
            }

            FHalfCarry = StaticHelpers.TestHalfCarry(HL.Word, source.Word, result);
            FNegative = false;
            FCarry = (HL.Word + source.Word) > 0xFFFF;

            HL.Word = result;
        }
示例#19
0
        private void _exx()
        {
            if (DebugMode)
            {
                DebugOut("EXX", null);
            }

            TStates += 4;

            RegisterPair tmp = BC;

            BC  = BC_;
            BC_ = tmp;

            tmp = DE;

            DE  = DE_;
            DE_ = tmp;

            tmp = HL;

            HL  = HL_;
            HL_ = tmp;
        }
示例#20
0
        private void _push_qq(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("PUSH", "{0}", register);

            }

            TStates += 11;

            SP.Word--;
            Memory[SP.Word] = source.HiByte;
            SP.Word--;
            Memory[SP.Word] = source.LoByte;
        }
示例#21
0
        private void _pop_qq(ref RegisterPair destination, string register)
        {
            if (DebugMode)
            {
                DebugOut("POP", "{0}", register);

            }

            TStates += 10;

            destination.LoByte = Memory[SP.Word++];
            destination.HiByte = Memory[SP.Word++];
        }
示例#22
0
        private void _inc_ss(ref RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("INC", "{0}", register);
            }

            TStates += 6;

            source.Word++;
        }
示例#23
0
        private void _sbc_hl_ss(RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("SBC", "HL, {0}", register);
            }

            TStates += 15;

            if(FCarry)
            {
                source.Word++;
            }

            ushort result = (ushort)(HL.Word - source.Word);

            FSign = StaticHelpers.TestBit(result, 15);
            FZero = result == 0;
            FHalfCarry = StaticHelpers.TestHalfCarry(HL.Word, source.Word, result);
            FPV = StaticHelpers.TestSubtractionOverflow(HL.Word, source.Word, result);
            FNegative = true;
            FCarry = (uint)(HL.Word - source.Word) > 0xFFFF;

            HL.Word = result;
        }
示例#24
0
        private void _ld_dd_nn(ref RegisterPair destination, string register)
        {
            byte loByte = Memory[PC.Word++];
            byte hiByte = Memory[PC.Word++];

            if (DebugMode)
            {
                DebugOut("LD", "{0}, #0x{1:X4}", register, loByte + (hiByte << 8));

            }

            TStates += 10;

            destination.HiByte = hiByte;
            destination.LoByte = loByte;
        }
示例#25
0
        //
        private void _dec_ss(ref RegisterPair source, string register)
        {
            if (DebugMode)
            {
                DebugOut("DEC", "{0}", register);

            }

            TStates += 6;

            source.Word--;
        }