1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-11 05:29:33 +00:00

Clearer documentation on push_stack

This commit is contained in:
Peter Evans 2018-04-13 18:01:17 -05:00
parent 3887f52119
commit 5db0c3b9c0

View File

@ -192,21 +192,15 @@ mos6502_free(mos6502 *cpu)
} }
/* /*
* Push a _16-bit_ number to the stack. Generally speaking, only * Push an 8-bit value to the stack, and then decrement the S register
* addresses are pushed to the stack, such that would be contained in * so that it points at the place where a new value would be deposited
* the PC register (which is 16-bit). * by a subsequent push. If S is decremented below 0, it rolls around to
* * FF.
* 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.
*/ */
void void
mos6502_push_stack(mos6502 *cpu, vm_8bit addr) mos6502_push_stack(mos6502 *cpu, vm_8bit addr)
{ {
mos6502_set(cpu, 0x100 + cpu->S, 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--; cpu->S--;
} }