# z80:Opcodes:XOR

From Learn @ Cemetech

XOR is an instruction that takes one 8-bit input and compares it with the accumulator. XOR is similar to Or, except for one thing: only 1 of the 2 test bits can be set or else it will result in a zero. The final answer is stored to the accumulator.

**0 and 0** result: 0

**0 and 1** result: 1

**1 and 0** result: 1

**1 and 1** result: 0

## Syntax

XOR op8

### Acceptable inputs

xor a xor b xor c xor d xor e xor h xor l xor ixh xor ixl xor iyh xor iyl xor (hl) xor (ix+n) xor (iy+n) xor n ;8 bit constant

## Effects

C and N flags cleared. P/V is parity, and rest are modified by definition.

## Uses

XORing numbers is used a lot to invert sprites and such. It is also very useful in bit-masking. See here for more information about bit-masking.

## T-States

r denotes 8-bit register.

r | 4 |

X | 7 |

(hl) | 7 |

(ix+X) | 19 |

(iy+X) | 19 |

## See Also

AND,BIT,CCF,CPL,OR,RES,SCF,SET