symbol or compound token) being inserted just before the cursor. The cursor can be moved left with
(shifted 5) or right with (shifted 8). The character before the cursor can be deleted with
RUBOUT
(shifted
0). (Note:- the whole line can be deleted by typing
EDIT
(shifted 1) followed by
NEWLINE
; or, if it is
INPUT
data, just by typing
EDIT
.)
When
NEWLINE
is pressed, the line is executed, entered into the program, or used as INPUT data as
appropriate, unless it contains a syntax error. In this case the symbol appears just before the error.
As program lines are entered, a listing is displayed in the top half of the screen. The manner in which the
listing is produced is rather complicated, and explained more fully in chapter 9, exercise 6. The last line to
be entered is called the current line and indicated by the symbol , but this can be changed using the
keys (shifted 6) and (shifted 7). If
EDIT
(shifted 1) is pressed, the current line is brought down to the
bottom part of the screen and can be edited.
When a command is executed or a program run, the screen is first of all cleared, & then output is
displayed in the top half of the screen and remains until a program line is entered, or
NEWLINE
is pressed
with an empty line, or or is pressed. In the bottom part appears a report of the form m/n where m is a
code showing what happened (see appendix B), & n is the number of the last line executed - or 0 for a
command. The report remains until a key is pressed (and indicates mode).
In certain circumstances, the
SPACE
key acts as a
BREAK
, stopping the computer with report D. This is
recognized
(i) at the end of a statement while a program is running,
(ii) while the computer is looking for a program on tape,
or (iii) while the computer is using the printer (or by accident trying to use it when it is not there).
The BASIC
Numbers are stored to an accuracy of 9 or 10 digits. The largest number you can get is about 10
38
, & the
smallest (positive) number is about 4 * 10
-39
.
A number is stored in the ZX81 in floating point binary with one exponent byte e (1 e 255), & four
mantissa bytes m (½ m 1). This represents the number m * 2
e-128
.
Since ½ m 1, the most significant bit of the mantissa m is always 1. Therefore in actual fact we can
replace it with a bit to show the sign - 0 for positive numbers, 1 for negative.
Zero has a special representation in which all 5 bytes are 0.
Numeric variables have names of arbitrary length, starting with a letter and continuing with letters and
digits. All these are significant, so that for instance LONGNAME & LONGNAMETOO are distinct names.
Spaces are ignored.
Control variables for
FOR
-
NEXT
loops have names a single letter long.
Numeric arrays have names a single letter long, which may be the same as the name of a simple
variable. They may have arbitrarily many dimensions of arbitrary size. Subscripts start at 1.
Strings are completely flexible in length. The name of a string consists of a single letter followed by $.
String arrays can have arbitraryily many dimensions of arbitrary size. The name is a single letter
followed by $ and may not be the same as the name of a string. All the strings in a given array have the
same fixed length, which is specified as an extra, final dimension in the
DIM
statement. Subscripts start at
1.
Slicing: Substrings of strings may be specified using slicers.
A slicer can be
(i) empty
or
(ii) numerical expression
or
(iii) optional numerical expression
TO
optional numerical expression
& is used in expressing a substring either by
(a) string expression (slicer)
or by
(b) string array variable (subscript,...,subscript, slicer)
which means the same as
string array variable (subscript,...,subscript)(slicer)