The contents of the first 40 bytes of RAM are as follows. Some of the variables are 1 byte, and can be POKEd and PEEKed directly. The others are each 2 bytes, and have the low order byte at the given address (n, say) and the high order byte at the next address. Thus to poke value v at address n do
POKE n.v
POKE n+t,v/256
and to PEEK at the value in address n use the expression
PEEK(n) +PEEK(n+1)*256
if the value is known to be in the range 0 to 32767, and something like
LET MSB = PEEK(n+1)
IF MSB>127 THEN LET MSB = MSB-256
LET VALUE = PEEK(n) + MSB*256
if it may be negative, i.e. if n is 16412 or 16414. The notes at the left hand side of the table have the following meanings:
X |
The variable should not be altered by POKE as this could cause the BASIC to hang up. |
N |
POKE will have no lasting effect, as the variable will be rewritten either at the end of the POKE statement or the next time "edit" mode is entered (either at the end of the run or to get some input). |
1 or 2 |
number of bytes in variable. |
U |
"unsigned" number in the range 0 to 65535; the BASIC will treat values in the range 32768 to 65535 as -32768 to -1 respectively. These are the only variables likely to yield negative values. |
Notes |
Address |
Contents |
1 |
16384 |
less than the "run-time error number": PEEK yields 255 normally, 1 less than the error code if an error has already occurred in this statement, eg PRINT (10^6 AND 0) OR PEEK (16384) prints 5 because 10**6 overflows. Do not POKE any value other than 255 or 0 to 8. POKE 16384,255 does nothing to 8) causes error n+1. Thus
POKE 16384, 8 is the same as STOP. |
X1 |
16385 |
sundry flags which control the BASIC system. |
|
|
|
2 |
16386 |
Statement number of current statement: POKE has no effect unless this is the last line in the program |
N2 |
16388 |
position in RAM of or cursor last line any input or editing was done |
2 |
16390 |
Statement number of [>] cursor |
X2
X2
X2
X2
X2 |
16392
16394
16396
16398
16400 |
VARS
E-LINE
D-LINE
DF-EA
DF-END |
See section 2a of Appendix 2 |
X1 |
16402 |
number of lines in lower part of screen, including blank line separating the two parts |
2 |
16403 |
statement number of first line on screen. The LIST statement sets this, and scrolling alters it |
2 |
16405 |
address of character or token preceding the marker. |
2 |
16407 |
statement number to which CONTINUE jumps |
N1 |
16409 |
sundry flags which control the syntax analysis |
|
N2 |
16410 |
address of next item in syntax table (very unlikely to be useful). |
U2 |
16412 |
"seed" for the random number generator. This is set by the RANDOMISE statement, q.v., and updated each time RND is called: see note below. |
U2 |
16414 |
number of frames displayed since the ZX-80 was switched on (more exactly, the remainder when this is divided by 65536). While a picture is on the screen, this number is incremented 50 times per second in the UK version, 60 times per second in the US version. |
N2 |
16416 |
address of 1st character of 1st variable name in last LET, INPUT, FOR, NEXT, or DIM statement. Thus in LET ABC= PEEK(16416) ABC is assigned the remainder when the address of the A is divided by 256. (Not likely to be very useful). |
N2 |
16418 |
value of the last expression or variable: in practice this is the parameter of PEEK so that PEEK(16418) yields 34 and PEEK(16419) yields 64 always |
X1 |
16420 |
position on line of next line character to be written to screen: 33 = lefthand column, 32 = second from left, etc, up to 2 = righthand column. Also, 1 = 1st column in next line because current line is full, 0
= 1st column on next line because end-of-line has been signalled. Thus after aPRINT not ending in a comma or a semi-colon PEEK(16420) always yields 0. It only yields 33 if the screen is empty (eg after CLS). |
X1 |
16421 |
position of current line on screen: 23 = top line, 22 = second line down, etc. |
X2 |
16422 |
address of the character after the closing bracket of the call of PEEK, or of the newline at the end of the POKE statement. |
The first line of program begins at address 16424.
The function RND generates a pseudo-random number from the current "seed" as follows:
let n be the seed.
if n is zero, take n = 65536 instead.
let m be the remainder when n*77 is divided by 65537.
if m is 65536, take m = o instead.
the result of RND(x) is now x*m/65536. the new seed is m.
The TAB function in printing can be implemented as follows:
1000 REM GO SUB; 1050 TABS TO
1001 REM COLUMN I
1010 REM GO SUB 1040 TABS TO
1011 REM COLUMN I OUTPUTTING
1012 REM AT LEAST ONE SPACE
1030
1040 PRINT";
1050 IF I+PEEK(16420) =33 THEN RETURN
1060 IF I = 0 THEN IF PEEK(16420)<2 THEN RETURN
1070 GO TO 1040
INDEX |
|
|
ABS |
|
91, 112 |
Addition |
|
35 |
AND |
|
50 |
Arithmetic overflow |
|
36 |
Arrays |
|
89 |
BASIC |
|
15, 103 |
Bit |
|
87 |
Brackets, use of |
|
33 |
Branches |
|
43 |
BREAK |
|
83, 116 |
Byte |
|
87 |
Character set |
|
75, 116 |
CHR$(n) |
|
75 |
CLEAR |
|
89, 115 |
CLS |
|
53, 115 |
CODE |
|
77, 111 |
Codes (for different characters) |
|
75 |
Commands |
|
16 |
Command mode |
|
23 |
Connections to tape recorder |
|
11 |
Connection to television |
|
9 |
CONTINUE |
|
84, 113 |
Control character |
|
71 |
Control variable |
|
57 |
Current line pointer |
|
26 |
Cursor |
|
22, 104 |
— keyword cursor |
|
22, 104 |
— letter cursor |
|
22, 104 |
Cursor control keys |
|
26, 103 |
DIM |
|
89, 105 |
Display |
|
9, 106 |
Display file |
|
108 |
Division |
|
36 |
EDIT |
|
26 |
Element — see Array |
|
|
Error codes (or messages) |
|
25, 99 |
Expressions |
|
35, 110 |
Expression evaluator |
|
109 |
Field |
|
71 |
Flowchart |
|
32, 43 |
FOR..-TO |
|
61, 115 |
GO SUB |
|
64, 115 |
GOTO |
|
47, 115 |
Graphics characters |
|
78 |
HOME — see Cursor control keys |
|
|
IF...THEN |
|
48,113 |
INPUT |
|
24, 113 |
Integer variables — see Variables |
|
|
Iterative programs |
|
57 |
Jumps |
|
47 |
Keyboard |
|
21, 22 |
Keyword |
|
22, 105 |
LET |
|
35 |
Line numbers |
|
17 |
LIST |
|
26, 114 |
LOAD |
|
11, 112 |
Literal number |
|
111 |
Literal string |
|
71 |
Loops |
|
61 |
Multiplication |
|
35 |
NEW |
|
22, 112 |
NEWLINE |
|
23 |
NEXT |
|
61, 115 |
NOT |
|
50 |
Operators |
|
35 |
— arithmetic |
|
35 |
— relational |
|
50 |
— logical |
|
50 |
OR |
|
50 |
PEEK |
|
88, 111 |
POKE |
|
87, 115 |
Power connections |
|
9 |
PRINT |
|
71, 114 |
Priority (of operators) |
|
37, 111 |
Program listing |
|
26 |
RAM |
|
103 |
RANDOMISE |
|
87, 115 |
Recording programs on tape |
|
11 |
REM |
|
63 |
RETURN |
|
64,115 |
RND |
|
87, 112 |
RUBOUT |
|
24, 105 |
RUN |
|
23, 113 |
SAVE |
|
11,113 |
SHIFT |
|
22 |
SPACE |
|
105, 110 |
Stack |
|
107 |
Statement numbers — see line numbers |
|
|
STOP |
|
85, 114 |
String variables — see Variables |
|
|
STR$ |
|
79 |
Subroutines |
|
64 |
Subscripts |
|
89 |
Subtraction |
|
36 |
Syntax error marker |
|
23, 104 |
System variables |
|
107, 121 |
TL$ |
|
77 |
Token |
|
22, 105 |
Truncation |
|
36 |
USR |
|
89, 112 |
Variables |
|
17 |
— integer variables |
|
17, 111 |
— string variables |
|
17, 110 |
Zero — confusion between letter O and number 0 |
|
22 |
|