Exercise 3: What Each Architecture's Stack Trades Away — Possible Solution ==================================================================== LC-3 (assembly1-7) — TRADES AWAY SPEED AND SIMPLICITY FOR FLEXIBILITY ------------------------------ LC-3's stack can live anywhere in memory the programmer chooses to point a register at, with no fixed location requirement at all. What it gives up in exchange is real hardware support entirely — every single push or pop has to be manually built out of several ordinary instructions (ADD to move the pointer, STR/LDR to actually move the value), rather than being a single dedicated operation. Flexibility in location comes at the cost of needing to hand-build the mechanism itself from scratch every time. 6502 (cpu8bit1-3) — TRADES AWAY LOCATION FLEXIBILITY FOR SPEED ------------------------------ The 6502 goes the opposite direction: it gets real, single-instruction hardware support (PHA/PLA/PHP/PLP), genuinely faster and simpler to use than LC-3's manual approach. What it gives up is WHERE the stack can live — it's permanently locked to page 1 ($0100-$01FF) because SP is only 8 bits wide, with no way to relocate it anywhere else in memory no matter what the program needs. Z80 (this chapter) — TRADES AWAY... COMPARATIVELY LITTLE, AT A REAL SILICON COST ------------------------------ The Z80's stack keeps the 6502's real hardware support (PUSH/POP as single instructions, even better — operating on a full 16-bit register pair per instruction rather than one byte) WHILE ALSO keeping LC-3's location flexibility, since its 16-bit SP can point anywhere in the full 64KB space rather than being locked to one page. Per this chapter's own closing point, the Z80's stack doesn't trade away much between these two specific dimensions (speed vs. flexibility) at all — but this doesn't mean it's "free": it's still paid for the same way every other piece of Z80 richness has been paid for throughout this course, as part of the chip's overall larger transistor budget (cpu8bit1-5) relative to the 6502's own leaner one. WHY THIS WORKS AS AN ANSWER ------------------------------ It addresses all three architectures using the chapter's own comparison table, names a specific, concrete trade-off for each of LC-3 and the 6502 (flexibility-for-speed and speed-for-flexibility, respectively), and is honest that the Z80's stack isn't a trade-off- free win either — it's paid for at the level of the chip's overall transistor budget rather than through any specific stack-level limitation.