AMSTRAD cpc 6128 User Instruction page 393

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

The
NOT
operator inverts each bit in the argument (0 becomes 1, and vice versa):
113 CLS
213 INPUT "The number of the month";month
313 IF NOTCmonth=6 OR
mont~=7
OR month=8) THEN 513
413 GOTO 113
513 PRINT
"It
can't be summer!"
Another major feature to consider is the fact that you can add together any number of
logical conditions (up to 'the maximum line length) to distiil the facts yet further.
113 INPUT "The number of the day";day
213 INPUT "The number of the month";month
313 IF NOTCmonth=12 OR month=1) AND day=29 THEN 513
413 CLS:GOTO 113
513 PRINT "This is neither December nor January, but
this might be a Leap year"
The result of a relational expression is either -
1
or 13. The bit representation for
-1
is all bits of the integer
=
1; for 13 all bits of the integer
=
13. The result of a logical
operation on two such arguments will yield either -
1
for True, or 13 for False.
Check this by adding lines 613 and to the above program:
613 PRINT NOT(month=12 OR month=1)
713 PRINT Cmonth=12 OR month=1)
.... and when the program is
run,
entering 29 for the day and, say, 2 for the month
will produce the answer in line 513, and the actual values returned by the logical
expressions in lines 6 13 and 713.
Finally, X 0
R
(eXclusive 0
R)
produces a true result as long as both arguments are
different.
The following summarises all these features in what's known as a 'truth table'. It's a
convenient way of illustrating what happens in a bit-wise logical operation.
Argument
A
1010
ArgumentB
0110
AND result
0010
OR result
1110
XORresult
1100
Chapter 9 Page 20
At your leisure ....

Advertisement

Table of Contents
loading

Table of Contents

Save PDF