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 #30 background imageLoading...
Page #30 background image
IF
condition
THEN GOTO
line number
Summary
Statements:
IF
,
STOP
Operations: =, <, >,
<=
,
>=
,
<>
,
AND
,
OR
Function:
NOT
Exercises
1.
<>
and = are opposites in the sense that
NOT
A=B is the same as A
<>
B
&
NOT
A
<>
B is the same as A=B
Persuade yourself that
>=
is opposite to <, and
<=
is opposite to > so that you can always get rid of
NOT
from in front of a relation by changing the relation to its opposite.
Also,
NOT
(a first logical expression
AND
a second)
is the same as
NOT
(the first)
OR NOT
(the second),
&
NOT
(a first logical expression
OR
a second)
is the same as
NOT
(the first)
AND NOT
(the second).
Using this you can work
NOT
s through brackets until eventually they are all applied to relations, & then
you can get rid of them. Thus, logically speaking,
NOT
is unnecessary. You might still find that using it
makes a program clearer.
2. BASIC can sometimes work along different lines from English. Consider, for instance, the English clause
'if A doesn't equal B or C'. How would you write this in BASIC? [The answer is not
'
IF
A
<>
B
OR
C' nor '
IF
A<>B
OR
A<>C']
Don't worry if you don't understand exercises 3, 4 & 5, the points covered in them are rather refined.
3. (For experts.)
Try
PRINT
1=2,1<>2
which you might expect to give a syntax error. In fact, as far as the computer is concerned, there is no such
thing as a logical value.
(i) =, <, >,
<=
,
>=
, and
<>
are all number valued binary operations, with priority 5. The result is 1 (for
true) if the relation holds, & 0 (for false)
if it does not.
(ii) In
IF
condition
THEN
statement
the condition can actually be any numeric expression. If its value is 0, then it counts as false, & any other
value counts as true. This the
IF
statement means exactly the same as
IF
condition
<>
0
THEN
statement
(iii)
AND
,
OR
&
NOT
are also number valued operations.

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