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.