diff --git a/src/rk65c02.c b/src/rk65c02.c index 5bdbd17..f01d784 100644 --- a/src/rk65c02.c +++ b/src/rk65c02.c @@ -124,6 +124,27 @@ rk65c02_step(rk65c02emu_t *e, uint16_t steps) { e->stopreason = STEPPED; } +void +rk65c02_dump_stack(rk65c02emu_t *e, uint8_t n) +{ + uint16_t stackaddr; + + stackaddr = STACK_END-n; + + while (stackaddr <= STACK_END) { + + if ((stackaddr == STACK_END-n) || !((stackaddr % 0x10))) + printf("stack %#02x: ", stackaddr); + + printf("%#02x ", bus_read_1(e->bus, stackaddr)); + + stackaddr++; + + if (!(stackaddr % 0x10)) + printf("\n"); + } +} + void rk65c02_dump_regs(rk65c02emu_t *e) { diff --git a/src/rk65c02.h b/src/rk65c02.h index 8bcbbf8..a2c9bd4 100644 --- a/src/rk65c02.h +++ b/src/rk65c02.h @@ -62,6 +62,7 @@ rk65c02emu_t rk65c02_init(bus_t *); void rk65c02_start(rk65c02emu_t *); void rk65c02_step(rk65c02emu_t *, uint16_t); void rk65c02_dump_regs(rk65c02emu_t *); +void rk65c02_dump_stack(rk65c02emu_t *, uint8_t); void rk65c02_irq(rk65c02emu_t *e); #endif