4 ms·
> - fixed 8-bit stack pointer so things like automatic variables and pass-by-value can't take up a lot of space. Also, the stack isn't addressable. The only st
by duskwuff 5y ago
> - fixed 8-bit stack pointer so things like automatic variables and pass-by-value can't take up a lot of space.
Also, the stack isn't addressable. The only stack operations the CPU natively supports are push and pop. If you want to access values anywhere else on the stack (say, if you're trying to spill a couple of local variables to the stack), you're going to have a bad time.
- electroly 5y agoI've never programmed on a 6502 before and have only read about it; isn't the stack addressable in the zero page?
- duskwuff 5y agoNo, the stack is in the next page up ($0100 - $01ff). While it's accessible as memory, the 6502 doesn't provide any addressing modes specific to this page; accessing it involves multiple instructions, and requires the use of the X register as a temporary.
- electroly 5y agoGot it; thank you for the clarification! Someday I'll try my hand at some 6502 assembly.