﻿ XOR (Exclusive Or)
XOR

Syntax

number XOR number
Description

XOR, at its most primitive level, is a Boolean operation, a logic function that takes in two bits and outputs a resulting bit. If given two bits, this function returns true if ONLY one of the bits are true, and false for any other combination. The truth table below demonstrates all combinations of a Boolean XOR operation:
Bit1     Bit2    Result
0         0        0
1         0        1
0         1        1
1         1        0

In ARMbasic, XOR is done as a bit-wise operation, unless it is part of a logical expression.  Logical expressions are those that compare values.  And when part of a logical expression the XOR is true if either logical expression are true, but not if both are true.

bit wise  00001111 XOR 00011110  is equal to  00010001

Notice how in the resulting number of the operation, reflects an XOR operation performed on each bit of the top operand, with each corresponding bit of the bottom operand.
Example

x=&H55
y=&H33
if (x xor y)=&H66 or x<y then print "OK"

' This will print OK as X XOR Y is &H66

Differences from PBASIC

• PBASIC XOR is always logical, and ^ is bit wise