Exercise 2: The Shadow Register Set's Real Purpose — Possible Solution ==================================================================== THE REAL, HISTORICAL PURPOSE ------------------------------ Per this chapter's own explanation, the shadow register set (a complete second copy of A/F/BC/DE/HL) was built specifically to make interrupt handling faster. Without it, an interrupt routine that needed to use registers for its own work would first have to save whatever the main program currently had sitting in those registers (typically by pushing them onto the stack), do its own work, and then restore the original values afterward before returning control back to the interrupted program. The shadow set lets an interrupt routine skip all of that: a single EXX instruction instantly swaps in an entirely separate, already-available set of registers, the interrupt routine uses those freely, and a second EXX swaps the original set back — with no stack save/restore of the main registers required at all. WHY THE 6502 HAS NOTHING COMPARABLE ------------------------------ The 6502 has exactly one copy of each of its registers (A, X, Y) — per cpu8bit1-3, there is no alternate or shadow set at all. Any 6502 interrupt routine that needs to use A, X, or Y for its own work has no choice but to save the current values (typically via PHA and similar) before using them, and restore them afterward — there's no hardware shortcut available to skip that save/restore step the way EXX provides on the Z80. WHY LC-3 HAS NOTHING COMPARABLE EITHER ------------------------------ LC-3's own I/O material (assembly1-8) only ever previewed polling — repeatedly checking a status register — as its interrupt-adjacent mechanism, and never introduced anything like a second register set at all. Any LC-3 routine needing extra registers would face the exact same save-before-use, restore-after-use pattern assembly1-7 already established for ordinary subroutine calls (saving R7, for instance) — there's no hardware-level shortcut analogous to EXX anywhere in LC-3's design. WHY THIS WORKS AS AN ANSWER ------------------------------ It states the shadow set's actual documented purpose (skipping register save/restore specifically during interrupt handling) rather than just calling it "extra registers," and explains concretely, for both other architectures, exactly what mechanism is missing that would be needed to achieve the same effect.