public static void INCFSZ(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); bool zeroFlag = false; if ((Befehl & 0x80) == 0) { RAM.ChangeW((byte)(regValue + 1)); if (RAM.W == 0) { zeroFlag = true; } } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), (byte)(regValue + 1)); if ((byte)(regValue + 1) == 0) { zeroFlag = true; } } if (zeroFlag == false) //Wenn das Zero Flag nicht gesetzt ist, führe nächsten Befehl aus { ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); } else //ansonsten überspringe den nächsten { RAM.RAM[bank, 2] += 2; RAM.incInternalTimer(2); } }
public static void CLRF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.ChangeRegister(bank, (byte)(Befehl & 0x007F), 0); RAM.ZeroBit(bank, Befehl); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void MOVWF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.incInternalTimer(1); ++RAM.RAM[bank, 2]; RAM.ChangeRegister(bank, (byte)(Befehl & 0x007F), RAM.W); }
public static void SUBLW(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte tempW = RAM.W; if ((0xFF & Befehl) >= RAM.W) { RAM.CarryBit(bank, 1); } else { RAM.CarryBit(bank, 0); //C } if ((Befehl & 0x0F) >= (RAM.W & 0x0F)) { RAM.DigitCarryBit(bank, 1); //DC, Komplement des Subtrahenten wird addiert } else { RAM.DigitCarryBit(bank, 0); } RAM.ChangeW((byte)((0xFF & Befehl) - RAM.W)); RAM.ZeroBit(bank); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void BTFSS(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); int tempBit = (int)Math.Pow(2, ((Befehl & 0x0380) >> 7)); if ((regValue & tempBit) == 0) { ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); } else { RAM.RAM[bank, 2] += 2; RAM.incInternalTimer(2); } }
public static void RRF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte tempState = RAM.RAM[0, 3]; byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); if ((regValue & 0x1) == 0) { RAM.CarryBit(bank, 0); //wenn das niedrigste Bit == 0, schreibe 0 in C-Bit } else { RAM.CarryBit(bank, 1); // ansonsten 1 in C-Bit } regValue = (byte)(regValue / 2); if ((tempState & 0x1) == 0) { regValue = (byte)(regValue & 0x7F); // wenn C-Bit == 0, dann wird 0 an das höchste Bit geschrieben } else { regValue = (byte)(regValue | 0x80); // ansonsten 1 } if ((Befehl & 0x80) == 0) { RAM.ChangeW(regValue); } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), regValue); } ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
static void SUBWF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); if (regValue >= RAM.W) { RAM.CarryBit(bank, 1); } else { RAM.CarryBit(bank, 0); //C } if ((regValue & 0x0F) >= (RAM.W & 0x0F)) { RAM.DigitCarryBit(bank, 1); } else { RAM.DigitCarryBit(bank, 0); //DC, wenn Low Byte von W } if ((Befehl & 0x80) == 0) { RAM.ChangeW((byte)(regValue - RAM.W)); RAM.ZeroBit(bank); } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), (byte)(regValue - RAM.W)); RAM.ZeroBit(bank, Befehl); } ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void ADDLW(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { if (((0xFF & Befehl) + RAM.W) > 0xFF) { RAM.CarryBit(bank, 1); } else { RAM.CarryBit(bank, 0); //C } if (((RAM.W & 0xF) + (Befehl & 0xF)) > 0xF) { RAM.DigitCarryBit(bank, 1); } else { RAM.DigitCarryBit(bank, 0); //DC, wenn die beiden Low Byte addiert >15 sind } RAM.ChangeW((byte)((0xFF & Befehl) + RAM.W)); RAM.ZeroBit(bank); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void ADDWF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); if ((regValue + RAM.W) > 0xFF) { RAM.CarryBit(bank, 1); } else { RAM.CarryBit(bank, 0); //C } if (((RAM.W & 0xF) + (regValue & 0xF)) > 0xF) { RAM.DigitCarryBit(bank, 1); } else { RAM.DigitCarryBit(bank, 0); //DC, wenn die beiden Low Byte addiert >15 sind } if ((Befehl & 0x80) == 0) { RAM.ChangeW((byte)(RAM.W + regValue)); RAM.ZeroBit(bank); } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), (byte)(RAM.W + regValue)); RAM.ZeroBit(bank, Befehl); } ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void XORLW(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.ChangeW((byte)((0xFF & Befehl) ^ RAM.W)); RAM.ZeroBit(bank); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void RETURN(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.PC = (byte)RAM.Stack.Last(); RAM.RAM[0, 2] = (byte)(RAM.PC & 0xFF); RAM.RAM[1, 2] = (byte)(RAM.PC & 0xFF); RAM.removeStack(); RAM.incInternalTimer(2); }
public static void CLRW(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.ChangeW(0); RAM.ZeroBit(bank, 0); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void BCF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); int tempBit = (int)Math.Pow(2, ((Befehl & 0x0380) >> 7)); RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), (byte)(regValue & ~tempBit)); ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
static public void g0t0(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { UInt16 newPC = (UInt16)((Befehl & 0x7FF) + ((RAM.RAM[0, 0xA] & 0x18) << 8)); //Berechnung des neuen PC RAM.PC = newPC; //PC wird in den RAM geschrieben RAM.RAM[0, 2] = (byte)(Befehl & 0xFF); RAM.RAM[1, 2] = (byte)(Befehl & 0xFF); //der PCL wird anhand des PC beschrieben RAM.incInternalTimer(2); }
public static void MOVF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { if ((Befehl & 0x80) == 0) { RAM.ChangeW(bank, (byte)(Befehl & 0x7F)); RAM.ZeroBit(bank); } else { RAM.ZeroBit(bank, Befehl); //lediglich Test auf Zero Bit } RAM.incInternalTimer(1); ++RAM.RAM[bank, 2]; }
static void SWAPF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); byte temp = (byte)(((regValue & 0x0F) * 16) + ((regValue & 0xF0) / 16)); if ((Befehl & 0x80) == 0) { RAM.ChangeW(temp); } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), temp); } ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void ANDWF(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { byte regValue = RAM.getRegisterValue(bank, (byte)(Befehl & 0x7F)); if ((Befehl & 0x80) == 0) { RAM.ChangeW((byte)(RAM.W & regValue)); RAM.ZeroBit(bank); } else { RAM.ChangeRegister(bank, (byte)(Befehl & 0x7F), (byte)(RAM.W & regValue)); RAM.ZeroBit(bank, Befehl); } ++RAM.RAM[bank, 2]; RAM.incInternalTimer(1); }
public static void NOP(Arbeitsspeicher RAM, byte bank) { RAM.incInternalTimer(1); ++RAM.RAM[bank, 2]; }
public static void MOVLW(UInt16 Befehl, Arbeitsspeicher RAM, byte bank) { RAM.incInternalTimer(1); ++RAM.RAM[bank, 2]; RAM.ChangeW((byte)(0xFF & Befehl)); }