XOR - The Bitwise XOR Command

The XOR command is a bitwise operation that preforms an exclusive OR to the value held in the accumulator with the specified value (argument) and resaves the new value into the accumulator.
"XOR"ing a bit will turn it on if they are different and turn it off if they match. It is used to find the difference between two bitfields.

Unlike the OR command none of the bits maintain state. All are processed by an XOR command.

Tasking ports often store data in bitfields and commands like XOR are useful for isolating the data you want.

Syntax

XOR x
Where x is the value, memory location, or tasking port you want to XOR against the accumulator value.

Example Bitfield for XOR command

ACC

1

1

0

0

1

1

0

0

MASK

0

1

1

0

1

0

0

1

RESULT

1

0

1

0

0

1

0

1

Examples

Example 1

{
...
LDA ^17,0   //Get the keyswitch port
XOR ~10     //Compare to previous state stored in ~10
CMP #0x01   //Was switch 1 changed?
BRZ Switch1 //Branch to switch 1 if it matches.
CMP #0x02   //Was switch 2 changed
BRZ Switch2 //Branch to switch 2 if it matches.
NULL        //End if nothing matches.
...
}

Example 2

This task checks dipswitches to see if any have changed. (CMP would work just as well)

{
...
ChangeCheck:
    LDA ^59,0       //Get the dipswitch port
    XOR ~10         //Compare to previous state stored in ~10
    BNE Change      //If anything is changed branch.
    Delay(.5)       //Wait a bit befor checking again
    BRA ChangeCheck //Go check again.
...
}