Exercise 3: How Prefix Bytes Exceed the Original 256-Opcode Ceiling — Possible Solution ==================================================================== THE ORIGINAL PROBLEM ------------------------------ A single byte can only represent 256 distinct values (0-255). If every Z80 instruction had to be identified by exactly one opcode byte, the absolute maximum number of distinct instructions available would be capped at 256 — and a meaningful chunk of that space was already spoken for by the instructions inherited directly from the 8080 (per this chapter's own compatibility requirement, those had to keep their existing encodings unchanged). There genuinely wasn't room left in a single byte's worth of opcode space to add anywhere near double the instruction count. HOW PREFIX BYTES SOLVE IT ------------------------------ Per this chapter's own explanation, the Z80 reserves four specific byte values — CB, DD, ED, and FD — not as ordinary instructions in their own right, but as SIGNALS: "the byte that follows this one should be looked up in a separate, additional table of instructions, not the normal one." Effectively, each prefix byte unlocks an entire second (or third, or fourth) 256-value opcode space, layered on top of the original one, accessible only when that specific prefix comes first. WHY THIS ACHIEVES ROUGHLY DOUBLE THE INSTRUCTION COUNT ------------------------------ Instead of being limited to whatever fits in the original single-byte space, the Z80 effectively gets several ADDITIONAL opcode spaces for free, each one addressable via its own two-byte (prefix + opcode) sequence. The original 8080-compatible instructions keep their exact original one-byte encodings untouched (preserving compatibility), while all of the Z80's genuinely new instructions live behind one of the four prefix bytes instead of competing for space in the original, already-full 256-value table. This is exactly how the chip reaches roughly double the 8080's own instruction count without ever breaking compatibility with a single existing 8080 opcode. WHY THIS WORKS AS AN ANSWER ------------------------------ It explains the original single-byte 256-value ceiling as a real, concrete limitation, then explains prefix bytes as a mechanism that unlocks additional opcode spaces on top of (not instead of) the original one — preserving every existing 8080 encoding while still making room for genuinely new instructions, which is the actual mechanism behind the roughly 2x instruction-count increase.