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 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); }