5 ms·
* There's also no stack-relative addressing mode (unless you move the stack pointer to the X register). * No instructions to push or pop anything besides A or
by NobodyNada 5y ago
* There's also no stack-relative addressing mode (unless you move the stack pointer to the X register).
* No instructions to push or pop anything besides A or status flags.
The combination of all of this basically means there's no good way to do local variables on the 6502. IIRC the C compilers typically reserve a bunch of memory for a separate "C stack" to avoid these limitations, but this is rather inefficient in terms of both performance and memory use.
Idiomatic 6502 assembly tends to have a mindset of "all variables are global", with only a few bytes for temporary/intermediate values that you have to juggle around carefully and deliberately.