Exercise 2: The 6502 Stack — One Real Improvement, One Real Constraint — Possible Solution ==================================================================== ONE GENUINE IMPROVEMENT: DEDICATED HARDWARE PUSH/PULL ------------------------------ Per this chapter's own comparison, assembly1-7's LC-3 stack had to be built entirely by hand out of ordinary ADD/STR/LDR instructions -- there was no register dedicated to being a stack pointer, and no instruction that understood "push" or "pop" as a single operation. The 6502 genuinely improves on this: SP is a real, dedicated hardware register, and a single instruction like PHA does everything LC-3 needed several separate instructions to accomplish (decrementing the pointer AND storing the value, in one step). This is a real, measurable improvement in both program size and clarity, not just a cosmetic difference. ONE GENUINE CONSTRAINT: THE STACK IS LOCKED TO PAGE 1 ------------------------------ The improvement comes with a real limitation, though: because SP is only 8 bits wide (not a full 16), it can only ever represent an address within a single fixed 256-byte page of memory -- page 1, $0100-$01FF -- with the high byte of every stack address permanently fixed to $01 by the hardware itself. LC-3's own software-built stack, by contrast, could in principle live anywhere in memory the programmer chose to point R6 at, since it wasn't tied to any specific hardware-fixed address range at all. So while the 6502's stack is faster and more convenient to use, it's also less flexible in where it can actually live. WHY THIS WORKS AS AN ANSWER ------------------------------ It picks one specific improvement (native single-instruction push/pull via PHA/PLA replacing LC-3's multi-instruction manual approach) and one specific constraint (the page-1 lock caused by SP's 8-bit width) rather than a vague "better in some ways, worse in others," and grounds both directly in the chapter's own stated mechanics.