SWAP Instruction



The instruction SWAP swaps the upper word with the lower word in a data register (bit 31-16 is exchanged with bit 15-0).

ADDRESS METHODS: Dn

DATA LENGTH: Word

FLAGS: X - U
N - Same as bit 31 in the data register
Z - Set if all 32 bits are zero, else cleared
C - 0
V - 0

SYNTAX: SWAP Dn

EXAMPLE CODE:   

    SWAP D0    if D0 contains FFFF0000, it would become 0000FFFF, which is useful for packing and unpacking BCDs