From 86ccf25e81032bcc9a221c775a7dd26b29f132a6 Mon Sep 17 00:00:00 2001 From: Sidney Cadot Date: Mon, 16 Dec 2024 17:12:07 +0100 Subject: [PATCH] CPU registers can be accessed from outside 6502.c. The linkage of the 'Regs' variable in 6502.c was changed from static to extern. This makes the Regs type visible (and even alterable) from the outside. This change helps tools to inspect the CPU state. In particular, it was implemented to facilitate a tool that verifies opcode functionality using the '65x02' testsuite. But the change is also potentially useful for e.g. an online debugger that wants to inspect the CPU state while the 6502 is neing simulated. --- src/sim65/6502.c | 2 +- src/sim65/6502.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 48a1d560d..9d857a8ed 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -391,7 +391,7 @@ CPUType CPU; typedef void (*OPFunc) (void); /* The CPU registers */ -static CPURegs Regs; +CPURegs Regs; /* Cycles for the current insn */ static unsigned Cycles; diff --git a/src/sim65/6502.h b/src/sim65/6502.h index cab734c6a..b6b621823 100644 --- a/src/sim65/6502.h +++ b/src/sim65/6502.h @@ -65,6 +65,9 @@ struct CPURegs { unsigned PC; /* Program counter */ }; +/* Current CPU registers */ +extern CPURegs Regs; + /* Status register bits */ #define CF 0x01 /* Carry flag */ #define ZF 0x02 /* Zero flag */