public static void MOVWF_Action(PIC16FInstruction instruction, PIC16FCpu cpu) { int address = cpu.GetBankedAddress(instruction); cpu.RAMMemoryAndRegisters[address].Register = cpu.WRegister.Register; cpu.IncrementPC(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }