We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Stack

From SnesLab
Jump to: navigation, search

The Stack is a LIFO (last-in, first-out) buffer which remembers the state of subroutines that are currently executing.

On the 65c816, the stack is always in bank zero.[3] It can be thousands of bytes deep.[1]

In emulation mode it wraps within page one.[2]

The stack grows towards zero, but the most recently pushed byte is nontheless called the top of the stack.[4] These instructions push things to the stack:

PL* instructions take one cycle more than their PH* counterparts because they have to increment the stack pointer to point to the top element before it can be pulled, whereas push instructions pipeline the decrement of SP so that it overlaps the opcode fetch of the next instruction. These instructions pull things from the stack:

Note the lack of PLK. PHS and PLS similarly do not exist, nor do any instructions performing the inverse of PEA, PEI, or PER.

See Also

References

  1. Wilson, Garth. https://wilsonminesco.com/816myths
  2. Clark, Bruce. http://www.6502.org/tutorials/65c816opcodes.html#5.1.1
  3. section 2.11 of 65c816 datasheet: https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf
  4. Eyes & Lichty, page 33