コード例 #1
0
 public static void INCFSZ_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
 {
     INCF_Action(instruction, cpu);
     if (cpu.StatusRegister.Z)
     {
         cpu.IncrementPC();
     }
     cpu.IncrementPC();
 }
コード例 #2
0
        public static void BTFSC_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int  address = cpu.GetBankedAddress(instruction);
            byte reg     = cpu.RAMMemoryAndRegisters[address].Register;

            if ((reg & (0x01 << instruction.AffectedBit)) == 0) // Do 2 increment of PC if the bit is clear
            {
                cpu.IncrementPC();
            }
            cpu.IncrementPC();
        }
コード例 #3
0
        public static void MOVWF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int address = cpu.GetBankedAddress(instruction);

            cpu.RAMMemoryAndRegisters[address].Register = cpu.WRegister.Register;
            cpu.IncrementPC();
        }
コード例 #4
0
        public static void CLRF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int address = cpu.GetBankedAddress(instruction);

            cpu.RAMMemoryAndRegisters[address].Register = 0;
            cpu.StatusRegister.Z = true;
            cpu.IncrementPC();
        }
コード例 #5
0
        public static void XORLW_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            byte   value  = instruction.Operand;
            UInt16 result = (UInt16)(value ^ cpu.WRegister.Register);

            cpu.WRegister.Register = (byte)result;
            cpu.StatusRegister.Z   = result == 0;
            cpu.IncrementPC();
        }
コード例 #6
0
        public static void BSF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int    address = cpu.GetBankedAddress(instruction);
            byte   reg     = cpu.RAMMemoryAndRegisters[address].Register;
            UInt16 result  = (UInt16)(reg | (0x01 << instruction.AffectedBit));

            cpu.RAMMemoryAndRegisters[address].Register = (byte)result;
            cpu.IncrementPC();
        }
コード例 #7
0
        public static void SUBLW_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            byte   value  = instruction.Operand;
            UInt16 result = (UInt16)(value - cpu.WRegister.Register);

            cpu.WRegister.Register = (byte)result;
            cpu.StatusRegister.Z   = result == 0;
            cpu.StatusRegister.C   = (result > 0xff);
            cpu.StatusRegister.DC  = (value & 0x0f + cpu.WRegister.Register & 0x0f) > 0x0f;
            cpu.IncrementPC();
        }
コード例 #8
0
        public static void MOVF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int  address       = cpu.GetBankedAddress(instruction);
            byte registerValue = cpu.RAMMemoryAndRegisters[address].Register;

            if (instruction.Destination == OpcodeDestinations.FileRegister)
            {
                cpu.RAMMemoryAndRegisters[address].Register = registerValue;
            }
            else
            {
                cpu.WRegister.Register = registerValue;
            }
            cpu.StatusRegister.Z = registerValue == 0;
            cpu.IncrementPC();
        }
コード例 #9
0
        public static void SWAPF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int    address       = cpu.GetBankedAddress(instruction);
            byte   registerValue = cpu.RAMMemoryAndRegisters[address].Register;
            byte   highNibble    = (byte)(registerValue >> 4);
            byte   lowNibble     = (byte)(registerValue & 0x0f);
            UInt16 result        = (UInt16)(lowNibble << 4 | highNibble);

            if (instruction.Destination == OpcodeDestinations.FileRegister)
            {
                cpu.RAMMemoryAndRegisters[address].Register = (byte)result;
            }
            else
            {
                cpu.WRegister.Register = (byte)result;
            }
            cpu.IncrementPC();
        }
コード例 #10
0
        public static void SUBWF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int    address       = cpu.GetBankedAddress(instruction);
            byte   registerValue = cpu.RAMMemoryAndRegisters[address].Register;
            UInt16 result        = (UInt16)(registerValue - cpu.WRegister.Register);

            if (instruction.Destination == OpcodeDestinations.FileRegister)
            {
                cpu.RAMMemoryAndRegisters[address].Register = (byte)result;
            }
            else
            {
                cpu.WRegister.Register = (byte)result;
            }
            cpu.StatusRegister.Z  = result == 0;
            cpu.StatusRegister.C  = (result > 0xff);
            cpu.StatusRegister.DC = (registerValue & 0x0f + cpu.WRegister.Register & 0x0f) > 0x0f;
            cpu.IncrementPC();
        }
コード例 #11
0
        public static void RRF_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
        {
            int    address       = cpu.GetBankedAddress(instruction);
            byte   registerValue = cpu.RAMMemoryAndRegisters[address].Register;
            UInt16 result        = (UInt16)(registerValue >> 1);

            result |= cpu.StatusRegister.C ? (UInt16)0x80 : (UInt16)0x00;

            if (instruction.Destination == OpcodeDestinations.FileRegister)
            {
                cpu.RAMMemoryAndRegisters[address].Register = (byte)result;
            }
            else
            {
                cpu.WRegister.Register = (byte)result;
            }
            cpu.StatusRegister.C = (registerValue & 0x01) != 0;
            cpu.IncrementPC();
        }
コード例 #12
0
 public static void NOP_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
 {
     cpu.IncrementPC();
 }
コード例 #13
0
 public static void MOVLW_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
 {
     cpu.WRegister.Register = instruction.Operand;
     cpu.IncrementPC();
 }
コード例 #14
0
 public static void CLRWDT_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
 {
     cpu.IncrementPC();
 }                                                                                                     // Nothing to do here until WDT is implemented
コード例 #15
0
 public static void CLRW_Action(PIC16FInstruction instruction, PIC16FCpu cpu)
 {
     cpu.WRegister.Register = 0;
     cpu.StatusRegister.Z   = true;
     cpu.IncrementPC();
 }