The System Variables of The Sinclair ZX81: Notes Address Name
The System Variables of The Sinclair ZX81: Notes Address Name
The bytes in memory from 16384 to 16508 are set aside for specific uses by the system. You can peek them to find out various
things about the system, and some of them can be usefully poked. They are listed here with their uses.
These are called system variables and carry names, but do not confuse them with the variables used by the BASIC. You cannot
use the names in a BASIC program; they are simply mnemonics that are used to make it easier to refer to the variables.
The number in column 1 is the number of bytes in the variable. For two bytes, the first one is the less significant byte - the
reverse of what you might expect. So to poke a value v to a two-byte variable at address n, use
1 16384 ERR_NR 1 less than the report code. Starts off at 255 (for -1), so PEEK 16384,
if it works at all, gives 255. POKE 16384,n can be used to force an
error halt: 0 W n W 14 gives one of the usual reports, 15 W n W 34 or
99 W n W 127 gives a nonstandard report, and 35 W n W 98 is likely
to mess up the display file.
X1 16385 FLAGS Various flags to control the BASIC system.
X2 16386 ERR_SP Address of first item on machine stack (after GOSUB returns).
2 16388 RAMTOP Address of first byte above BASIC system area. You can poke this to
make NEW reserve space above that area (see Chapter 26) or to fool
CLS into setting up a minimal display file (Chapter 27).
N2 16391 PPC Line number of statement currently being executed. Poking this has no
lasting effect except in the last line of the program.
S2 16398 DF_CC Address of PRINT position in display file. Can be poked so that
PRINT output is sent elsewhere.
SX2 16406 CH_ADD Address of the next character to be interpreted: the character after the
argument of PEEK, or the ENTER at the end of a POKE statement.
SN2 16415 MEM Address of area used for calculator’s memory. (Usually MEMBOT
but not always.)
S2 16419 S_TOP The number of the top program line in automatic listings.
SN1 16424 MARGIN Number of blank lines above or below picture - 31.
SN2 16432 T-ADDR Address of next item in syntax table (very unlikely to be useful).
S2 16434 SEED The seed for RND. This is the variable that is set by RAND.
S2 16436 FRAMES Counts the frames displayed on the television. Bit 15 is 1. Bits 0 to 14
are decremented for each frame sent to the television. This can be used
for timing, but PAUSE also uses it. PAUSE resets bit 15 to 0 and puts
in bits 0 to 14 the length of the pause. When these have been counted
down to zero, the pause stops. If the pause stops because of a key
depression, bit 15 is set to 1 again.
S1 16440 PR_CC Less significant byte of address of next position for LPRINT to print
at (in PRBUFF).
S1 16443 CDFLAG Various flags. Bit 7 is on (1) during compute and display mode.
Source: ZX81 BASIC Programming by Steven Vickers, (c) Sinclair Research Limited.