Decoding DD and FD Prefixes
Instructions with either the
FD prefixes affect those instructions that operate
against the memory addressed by
changing them to use either the
IY registers with an offset.
Instructions that refer directly to the
HL register will then act directly against either
For those that refer to
(HL), i.e. the memory pointed to by
then the instructions use an additional relative offset that's added to either the
IY registers, and are written as
Instructions with the
DD prefix use the
FD prefix uses the
DDCB and FDCB Prefixes
FD prefixes extends though the
CB prefix as it does for normal instructions.
Just like the CB prefix
The format of the instruction also changes slightly as they change the behaviour of the existing instructions with
These instructions are all four bytes long with the third byte consisting of the offset.
For example: The
RLC (HL) is encoded as CB06.
DD prefix this becomes
RLC (IX+d) but the instruction is formatted as
FD prefix this becomes
RLC (IY+d), formatted as
Note that the offset
d is before the final part of the operand, not after as you might expect.
All of these have either DD or FD as the previous prefix byte and a displacement immediately after them.