Skip to main content

XOR

Compute the bitwise exclusive OR of the two operands, storing the result in the left operand.

OpcodeBytesCyclesFormExample
$8233XOR B:_, {U_BYTE}XOR B:1, 123
$D243XOR P:_, {U_PAIR}XOR P:2, 12345
$8333XOR I:_, {U_BYTE}XOR I:4, 123
$D343XOR I:_, {U_PAIR}XOR I:4, 12345
$8433XOR I:_, XHEX {XINT}XOR I:4, XHEX $D000_0000
$8533XOR B:_, B:_XOR B:1, B:2
$8633XOR P:_, P:_XOR P:2, P:4
$8733XOR I:_, I:_XOR I:4, I:8
Condition flagOutput
zero (ZF)If the result is zero, this flag is 1; otherwise it is 0.
negative (NF)This flag is updated with the highest bit of the result.
For example, if XOR B:0, $FF stores $80 in B:0, then NF will be 1.
overflow (OF)This flag is always 0.
carry (CF)This flag is always 0.

Notes

  • XOR is commonly used for reversing bits.

  • Large literal values such as $D000_0000 must be compatible with XHEX encoding.