From a92c995907b3fa93eee241234cb583b944146e10 Mon Sep 17 00:00:00 2001 From: rs <> Date: Mon, 13 Oct 2025 19:53:20 -0500 Subject: [PATCH] Add push, pop, and pc set commands to emulator --- projects/cpu_0/asm/emu.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/projects/cpu_0/asm/emu.py b/projects/cpu_0/asm/emu.py index 473d393..4c2e9af 100755 --- a/projects/cpu_0/asm/emu.py +++ b/projects/cpu_0/asm/emu.py @@ -255,8 +255,11 @@ def main() -> int: emu.p_push(0) emu.pc = 0 emu.dump() - emu.run_until('vga_console_putc') + emu.run_until('start') emu.dump() + for i in range(256): + addr = emu.symbol_to_addr('vga_scr') + emu.st8(addr + (i*2), i) i = '' while True: p = i @@ -299,6 +302,36 @@ def main() -> int: elif c[0] == 's': emu.step() emu.dump() + elif c[0] == 'push': + a = c[1] + if a[0].isdigit(): + a = int(a, 0) + else: + a = emu.symbol_to_addr(a) + emu.p_push(a) + emu.dump() + elif c[0] == 'rpush': + a = c[1] + if a[0].isdigit(): + a = int(a, 0) + else: + a = emu.symbol_to_addr(a) + emu.r_push(a) + emu.dump() + elif c[0] == 'pop': + emu.p_pop() + emu.dump() + elif c[0] == 'rpop': + emu.r_pop() + emu.dump() + elif c[0] == 'pc': + a = c[1] + if a[0].isdigit(): + a = int(a, 0) + else: + a = emu.symbol_to_addr(a) + emu.pc = a + emu.dump() return 0 -- 2.43.0