Exchanges two 16-bit values.
ex af,af' ex de,hl ex (sp),hl ex (sp),ix ex (sp),iy
Flags are preserved.
EX DE,HL exchanges HL with DE. Note that IX and IY do not work with this command.
EX (SP),HL exchanges HL with the last pushed value on the stack.
EX AF,AF' exchanges AF with its shadow register. This is mostly used as an alternative to pushing AF to the stack during interrupts. Note that the flags will most likely not be the same after this command.