EasyManuals Logo

Sinclair ZX81 User Manual

Sinclair ZX81
92 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #31 background imageLoading...
Page #31 background image
Read through the chapter again, in the light of this revelation, making sure that it all works.
In the expressions X
AND
Y, X
OR
Y &
NOT
X, X and Y will each usually take the value 0 or 1, for false
or true. Work out the ten different combinations & check that they do what you expect
AND
,
OR
&
NOT
to
do.
4. Try this program:
10
INPUT
A
20
INPUT
B
30
PRINT
(A
AND
A
>=
B)+(B
AND
A<B)
40
GOTO
10
Each time it prints the larger of the two numbers A & B - why?
Convince yourself that you can think of
X AND Y
as meaning
'X if Y (else the result is 0)'
& of
X
OR
Y
as meaning
'X unless Y (in which case the result is 1)'
An expression using
AND
&
OR
like this is called a conditional expression. An example using
OR
could
be
LET
RETAIL PRICE=PRICE LESS VAT*(1.15
OR
V$="ZERO RATED")
Notice how
AND
tends to go with addition (because its default value is 0), &
OR
tends to go with
multiplication (because its default value is 1).
5. You can also make string valued conditional expressions, but only using
AND
.
so it means 'X$ if Y (else the empty string)'.
Try this program, which inputs two strings & puts them in alphabetical order.
10
INPUT
A$
20
INPUT
B$
X
AND
Y has the
value
{ X if Y is non-zero (counting as
true)
{ 0 if Y is zero (counting as
false)
X
OR
Y has the
value
{ 1 if Y is non-zero
{ X if Y is zero
NOT
X has the
value
{ 0 if X is non-zero
{ 1 if X is zero
X$
AND
Y$ has the value
{ X$ if Y is non-zero
{ if Y is zero

Other manuals for Sinclair ZX81

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair ZX81 and is the answer not in the manual?

Sinclair ZX81 Specifications

General IconGeneral
ProcessorZilog Z80A
Processor Speed3.25 MHz
ROM8 KB
InputMembrane keyboard
StorageCassette tape
Power Supply9V DC
Dimensions167 mm x 40 mm x 175 mm
Release Year1981
ManufacturerSinclair Research
Weight350 g
Operating SystemSinclair BASIC
RAM1 KB
PortsTV out, expansion port
DisplayTelevision (RF modulator output)

Related product manuals