From 5db0c3b9c0fe9c9b53869ae4639a5b9c6f4a6e52 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 13 Apr 2018 18:01:17 -0500 Subject: [PATCH] Clearer documentation on push_stack --- src/mos6502/mos6502.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/mos6502/mos6502.c b/src/mos6502/mos6502.c index 98cfa9a..d6bca70 100644 --- a/src/mos6502/mos6502.c +++ b/src/mos6502/mos6502.c @@ -192,21 +192,15 @@ mos6502_free(mos6502 *cpu) } /* - * Push a _16-bit_ number to the stack. Generally speaking, only - * addresses are pushed to the stack, such that would be contained in - * the PC register (which is 16-bit). - * - * The stack is contained within a single page of memory, so you would - * be right in observing that the stack can contain at most 128, not - * 256, addresses. + * Push an 8-bit value to the stack, and then decrement the S register + * so that it points at the place where a new value would be deposited + * by a subsequent push. If S is decremented below 0, it rolls around to + * FF. */ void mos6502_push_stack(mos6502 *cpu, vm_8bit addr) { mos6502_set(cpu, 0x100 + cpu->S, addr); - - // And finally we need to increment S by 2 (since we've used two - // bytes in the stack). cpu->S--; }