User`s manual
8-17
NOT 0 = -1 The bit complement of binary 0 to 16 places is six-teen
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 TRS-80's input
ports which reflect the state of some external device. This requires the
TRS-80 Expansion Interface.
Bit position 7 is the most significant bit of a byte, while position 0 is the least
significant.
For instance, suppose bit 1 of I/O port 5 is 0 when the door to Room X is
closed, and 1 if the door is open. The following program will print "Intruder
Alert" if the door is opened:
10 IF INP(5) AND 2 THEN PRINT "INTRUDER ALERT": GOTO 100
20 GOTO 10
See Chapter 1, "Logical Operators".










