Reading Decoding Z80 Opcodes, There's a section about the 0xDD
prefix. This instruction prefix causes the next instruction to use the IX
register instead of the HL
register. That makes sense. HL
and IX
(also IY
) are designed for holding pointers. That's why there's such an efficient encoding for (HL)
(called M
in Intel's parlance). This question is also about the 0xFD
instruction prefix which does the same but for IY
.
Anyway, there's this comment about prefix 0xDD
in particular:
If the next opcode makes use of HL, H, L, but not (HL), any occurrence of these will be replaced by IX, IXH, IXL respectively. An exception of this is EX DE, HL which is unaffected.
I think it's weird that EX DE, HL
is unaffected by this instruction prefix. I can see the utility of being able to efficiently switch pointers around. So has this been "special-cased" somehow to remove the possibility of exchange DE
with the index registers?