z80:Opcodes:EX

From Learn @ Cemetech
Revision as of 22:16, 5 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Exchanges two 16-bit values.

Syntax

   ex op16,op16

Allowed Instructions

   ex af,af'
   ex de,hl
   ex (sp),hl
   ex (sp),ix
   ex (sp),iy

Effects

Flags are preserved.

Uses

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.

T-States

de, hl 4
af, af' 4
(sp),hl 19
(sp),ix 19
(sp),iy 19

See Also

EXX