From e62b66dd08ca445d1f7e5b802a503ad3ec83b2df Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Fri, 8 Aug 2025 23:57:26 +1000 Subject: added branching to compiler and comment generation --- Emulator/Chip/Q1Cpu.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'Emulator/Chip/Q1Cpu.cs') diff --git a/Emulator/Chip/Q1Cpu.cs b/Emulator/Chip/Q1Cpu.cs index d1fcf7a..16489e4 100644 --- a/Emulator/Chip/Q1Cpu.cs +++ b/Emulator/Chip/Q1Cpu.cs @@ -5,10 +5,6 @@ using Assembler; public partial class Q1Cpu { - public const u16 StackStart = 0x2FFF; - public const u16 StackLength = 16 * 2; // 16 16-bit values - public const u16 ProgramStart = 0x1FFF; - public Random Random; public u16 AX = 0; // Accumulator register @@ -35,10 +31,10 @@ public partial class Q1Cpu this.V = new u16[16]; - this.SP = Q1Cpu.StackStart; + this.SP = Q1Layout.StackStart; this.PushStack(0xFFFF); - this.PC = Q1Cpu.ProgramStart; + this.PC = Q1Layout.ProgramStart; } public void Clock() @@ -88,7 +84,7 @@ public partial class Q1Cpu private void PushStack(u16 value) { - if (this.SP + 2 >= Q1Cpu.StackStart + Q1Cpu.StackLength) + if (this.SP + 2 >= Q1Layout.StackStart + Q1Layout.StackLength) throw new InvalidOperationException("Stack overflow"); this.Bus.WriteWord(this.SP, value); @@ -97,7 +93,7 @@ public partial class Q1Cpu private u16 PopStack() { - if (this.SP - 2 < Q1Cpu.StackStart) + if (this.SP - 2 < Q1Layout.StackStart) throw new InvalidOperationException("Stack underflow"); this.SP -= 2; -- cgit v1.3.1