Commodore VIC-20 User Manual page 89

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

Chapter 3: Programming the VIC 20 Computer
75
Boolean operators operate on integer operands one binary digit at a
time. VIC BASIC stores all numbers in binary format, using two's comple-
ment notation to represent negative numbers. Therefore we can illustrate an
AND operation as follows:
43 AND 137 = 9 - - - - - - - - - ,
I
L . . . I -
-
-
-
:
89
16 -
10001001
L - - - - - - - - 2 B I6 -OOlOlOll
09
16 -
00001001
Here is an OR operation.
43 OR 137= 171 - - - - - - - - - ,
I
\ . . . 1 -
-
-
:
89
16 -
10001001
~-----"2BI6
- 00 10 lOll
AB I6 -lOlOlOll
Here are two NOT operations.
NOT
43
=
212 - - - - - - - - - - ,
L . . I
- - - _ I
2B I6 - 00101011
l
l
D4
16 -
1l010100
NOT
137=
1 1 8 - - - - - - - - - - .
IL..
- - - _ I
89
16 _
10001001
l
l
76
16 -
01l1O1l0
If operands are not integers, they are converted to integer form; the
Boolean operation is performed, and the result is returned as a 0 or 1.
If a Boolean operator has relational operands, then the relational
operand is evaluated to -lor 0 before the Boolean operation is performed.
Thus the operation
A= I ORC< 2
is equivalent to

Advertisement

Table of Contents
loading

Table of Contents