Commodore PET User Manual page 81

Table of Contents

Advertisement

If the terms to be operated on are not already integers. they are converted to
integer form; the Boolean operation is performed. and the result is presented as a
single integer value. This is also how Boolean operations work on the true/false
expressions. That is. there is no operational difference between a mixed Boolean
operation such as:
A=1 OR C<2
and a simple Boolean operation su ch as:
A OR C
The only practical difference is that. since a relational expression is evalu-
ated to -1 or O. the Boolean operation will always be performed on quantities of
-1 and 0 for a relational expression. For example:
IF A=B AND C<D GOTO 40
First the relational expressions are evaluated. Assume that the first expression is
true and the second one is false. In effect. the following Boolean expression is
evaluated:
IF -1 AND 0 GOTO 40
Performing the AND yields a 0 result:
IF 0 GOTO 40
Recall that a single term has an implied "< >0" following it. The expression
therefore becomes:
IF 0< >0 GOTO 40
Thus. the branch is not taken.
ln contrast. a Boolean operation performed on two variables may yield any
integer number:
IF A% AND B% GOTO 40
Assume that A%=255 and B%=240. The Boolean operation 255 AND 240 yields
240. The statement. therefore. is equivalent to:
IF 240 GOTO 40
or. with the "< >0":
IF 240 < >0 GOTO 40
Therefore the branch will be taken.
Now compare the two assignment statements:
A = A AND 10
A=A<lO
ln the first example. the current value of A is logically ANDed with 10 and
the result becomes the new value of A. A must be in the integer range ±32767. In
the second example. the relational expression A < lOis evaluated to -1 or 0, so A
must end up with a value of -1 or O.
68

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents