NOT IF NOT Q3 THEN 4 If expression "NOT Q3" is true (Because
Q3 is false), then branch to line 4
Note: NOT -1=0 (NOT true=false)
AND, OR, and NOT can be used for bit manipulation, and for performing boolean operations.
These three operators convert their arguments to sixteen bit, signed two's-complement integers in
the range -32768 to +32767. They then perform the specified logical operation on them and return
a result within the same range. If the arguments are not in this range, an "FC" error results.
The operations are performed in bitwise fashion, this means that each bit of the result is obtained
by examining the bit in the same position for each argument.
The following truth table shows the logical relationship between bits:
OPERATOR ARGUMENT 1 ARGUMENT 2 RESULT
-------- ---------- ---------- ------
AND 1 1 1
0 1 0
1 0 0
0 0 0
OR 1 1 1
1 0 1
0 1 1
0 0 0
NOT 1 - 0
0 - 1
EXAMPLES: (In all of the examples below, leading zeroes on binary numbers are not shown.)
63 AND 16=16 Since 63 equals binary 111111 and 16 equals binary 10000, the result
of the AND is binary 10000 or 16.
15 AND 14=14 15 equals binary 1111 and 14 equals binary 1110, so 15 AND 14
equals binary 1110 or 14.
-1 AND 8=8 -1 equals binary 1111111111111111 and 8 equals binary 1000, so
the result is binary 1000 or 8 decimal.
4 AND 2=0 4 equals binary 100 and 2 equals binary 10, so the result is binary 0
because nons of the bits in either argument match to give a 1 bit in
the result.
4 OR 2=6 Binary 100 OR'd with binary 10 equals binary 110, or 6 decimal.
10 OR 10=10 Binary 1010 OR'd with binary 1010 equals binary 1010, or 10 decimal.
-1 OR -2=-1 Binary 1111111111111111 (-1) OR'd with binary 1111111111111110
(-2) equals binary 1111111111111111, or -1.
NOT 0=-1 The bit complement of binary 0 to 16 places is sixteen ones
(1111111111111111) or -1. Also NOT -1=0.
NOT X NOT X is equal to -(X+1). This is because to form the sixteen bit
two's complement of the number, you take the bit (one's)
complement and add one.
NOT 1=-2 The sixteen bit complement of 1 is 1111111111111110, which is
equal to -(1+1) or -2.
A typical use of the bitwise operators is to test bits set in the computer's locations which reflect
the
state of some external device.
Bit position 7 is the most significant bit of a byte, while position 0 is the least significant.