public static bool F_RET() { CPU.MoveProgramCounter(CPU.PopStack()); // skips the call fuction it goes back to CPU.StepProgramCounter(I_CALL.Arguments); return(true); }
public static bool F_PRINTIL() { // fetch data byte len = Memory.Read((ushort)(CPU.ProgCtr + 1)); char key = (char)Memory.Read(CPU.I); // exit if out of range if (CPU.I + len >= Memory.Size) { return(false); } string text = ""; // if not valid print space if (key == 0 || key == 32) { text = ""; CLI.Write(" "); } else { for (int i = 0; i < len; i++) { char c = ((char)Memory.Read(CPU.I + i)); if (c >= 32 && c < 127) { text += c.ToString(); } } CLI.WriteLine(text); } CPU.StepProgramCounter(I_PRINTIL.Arguments); return(true); }
public static bool F_STORI() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); Memory.Write(CPU.I, CPU.Registers[r]); CPU.StepProgramCounter(I_STORI.Arguments); return(true); }
public static bool F_CURGY() { byte rx = Memory.Read((ushort)(CPU.ProgCtr + 1)); CPU.Registers[rx] = (byte)CLI.CursorY; CPU.StepProgramCounter(I_CURGY.Arguments); return(true); }
public static bool F_LOADW() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); CPU.SetRegister(r, CPU.W); CPU.StepProgramCounter(I_LOADW.Arguments); return(true); }
public static bool F_CURSY() { byte rx = Memory.Read((ushort)(CPU.ProgCtr + 1)); CLI.SetCursorPos(CLI.CursorX, CPU.Registers[rx]); CPU.StepProgramCounter(I_CURSY.Arguments); return(true); }
public static bool F_BCOL() { byte col = Memory.Read((ushort)(CPU.ProgCtr + 1)); CLI.BackColor = ByteToColor(col); CPU.StepProgramCounter(I_BCOL.Arguments); return(true); }
public static bool F_SUBI() { byte b = Memory.Read((ushort)(CPU.ProgCtr + 1)); CPU.SetI((ushort)(CPU.I - b)); CPU.StepProgramCounter(I_SUBI.Arguments); return(true); }
public static bool F_XOR() { byte rx = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 2)); CPU.SetRegister(rx, (byte)(CPU.Registers[rx] ^ CPU.Registers[ry])); CPU.StepProgramCounter(I_XOR.Arguments); return(true); }
public static bool F_STORW() { byte left = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte right = Memory.Read((ushort)(CPU.ProgCtr + 2)); Memory.Write(BytesToAddress(left, right), CPU.W); CPU.StepProgramCounter(I_STORW.Arguments); return(true); }
public static bool F_SUB() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte b = Memory.Read((ushort)(CPU.ProgCtr + 2)); CPU.SetRegister(15, (byte)(CPU.Registers[r] > b ? 1 : 0)); CPU.SetRegister(r, (byte)(CPU.Registers[r] - b)); CPU.StepProgramCounter(I_SUB.Arguments); return(true); }
public static bool F_LOADI() { byte left = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte right = Memory.Read((ushort)(CPU.ProgCtr + 2)); ushort addr = BytesToAddress(left, right); CPU.SetI(addr); CPU.StepProgramCounter(I_LOADI.Arguments); return(true); }
public static bool F_STORA() { byte b = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte left = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte right = Memory.Read((ushort)(CPU.ProgCtr + 3)); ushort addr = BytesToAddress(left, right); Memory.Write(addr, b); CPU.StepProgramCounter(I_STORA.Arguments); return(true); }
public static bool F_SNER() { byte rx = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte next = Memory.Read((ushort)(CPU.ProgCtr + 3)); CPU.StepProgramCounter(I_SNER.Arguments); if (CPU.Registers[rx] != CPU.Registers[ry]) { CPU.StepProgramCounter(GetInstruction(next).Arguments + 1); } return(true); }
public static bool F_WAIT() { // get key ConsoleKeyInfo key = Console.ReadKey(true); char c = (char)0; // character if (key.KeyChar >= 32 && key.KeyChar < 127) { c = key.KeyChar; } // special keys if (key.Key == ConsoleKey.Enter) { c = (char)240; } if (key.Key == ConsoleKey.Backspace) { c = (char)241; } if (key.Key == ConsoleKey.LeftArrow) { c = (char)242; } if (key.Key == ConsoleKey.RightArrow) { c = (char)243; } if (key.Key == ConsoleKey.UpArrow) { c = (char)244; } if (key.Key == ConsoleKey.DownArrow) { c = (char)245; } // send data CPU.SetW((byte)c); // redraw debug text if (CPU.DebugVisible) { CPU.DrawDebug(); } CPU.StepProgramCounter(I_WAIT.Arguments + 1); return(true); }
public static bool F_PIXA() { byte col = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte rx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (col > 0xF) { col = 0xF; } TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], (Color)col); CPU.StepProgramCounter(I_PIXA.Arguments); return(true); }
public static bool F_PIX() { byte col = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte xx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte yy = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (col > 0xF) { col = 0xF; } TextGraphics.SetPixel(xx, yy, (Color)col); CPU.StepProgramCounter(I_PIX.Arguments); return(true); }
public static bool F_PIXAR() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte rx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (CPU.Registers[r] <= 0xF) { TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], (Color)CPU.Registers[r]); } else { TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], Color.White); } CPU.StepProgramCounter(I_PIXAR.Arguments); return(true); }
public static bool F_RAND() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte b = Memory.Read((ushort)(CPU.ProgCtr + 2)); try { byte rand = (byte)DataUtils.RandNum(b); CPU.SetRegister(r, rand); CPU.StepProgramCounter(I_RAND.Arguments); } catch (Exception ex) { Runner.IsRunning = false; CLI.Write("[FATAL] " + Color.Red); CLI.WriteLine(ex.Message, Color.White); } return(true); }
public static bool F_PRINT() { // fetch data byte len = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte left = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte right = Memory.Read((ushort)(CPU.ProgCtr + 3)); ushort addr = BytesToAddress(left, right); char key = (char)Memory.Read(addr); // exit if out of range if (addr + len >= Memory.Size) { return(false); } string text = ""; // if not valid print space if (key == 0 || key == 32) { text = ""; CLI.Write(" "); } else { for (int i = 0; i < len; i++) { char c = ((char)Memory.Read(addr + i)); if (c >= 32 && c < 127) { text += c.ToString(); } } if (text.Length > 0) { CLI.Write(text); } } CPU.StepProgramCounter(I_PRINT.Arguments); return(true); }