Skip to content

ZX80 BASIC reference ​

Every command, function and operator in Sinclair ZX80 integer BASIC.

In this reference: Hardware · Escape codes · File formats · Argument notation

Notes and caveats ​

  • Arithmetic is 16-bit signed integer only — there is no floating point, and division truncates.
  • One numbered statement per line; line numbers must be strictly ascending. There are no multi-statement lines and no ELSE.
  • Variable names are single letters (A–Z, with a $ suffix for strings); strings are taken apart with TL$ and CODE rather than slicing.
  • AND, OR and NOT combine their operands bit by bit — 5 AND 3 is 1 and NOT 5 is -6 — and a true comparison is -1. The ZX81 that replaced this machine answers 5 and 0 and 1 to the same three expressions, so logic is one of the things a program carried between the two Sinclairs has to be read for.
  • There is no <=, >= or <>. Combine the ones there are: NOT A<B is how a program says A>=B.
  • The power operator is **, folding left to right, on integers like everything else here.

Command Function Operator

Syntax & description
-<number> - <number> | -<number>
Subtracts one integer from another, or negates a single value. All arithmetic is integer-only with no fractional part.
,PRINT <expr>, <expr>
PRINT separator that moves the cursor to the next tab field before printing the following item, lining output up into columns.
;PRINT <expr>;<expr>
PRINT separator that joins items together with no spacing, printing the next value immediately after the previous one.
((
Opens a parenthesised group, used to control evaluation order or to index an array element.
))
Closes a parenthesised group, such as an array subscript or a bracketed sub-expression.
*<number> * <number>
Multiplies two integers together.
**<number> ** <number>
Raises one integer to the power of another. The ZX80 spells exponentiation as ** rather than ^, and the result is an integer.
/<number> / <number>
Integer division: the result is truncated to a whole number, since the ZX80 has no floating point and discards any remainder.
+<number> + <number>
Adds two integers together.
<<number> < <number>
Less-than comparison. There is no <= operator; combine with AND/OR/NOT instead.
=<number> = <number>
Tests two values for equality in conditions, and also assigns a value in a LET statement.
><number> > <number>
Greater-than comparison. There is no >= operator; combine with AND/OR/NOT instead.
ABSintegral functionABS(<number>)
Returns the absolute (unsigned) value of the argument.
AND<number> AND <number>
Logical AND of two conditions, giving a non-zero (true) result only when both operands are non-zero.
CHR$integral functionCHR$(<number>)
Returns the single-character string for the given ZX80 character code. The inverse of CODE.
CLEARCLEAR
Deletes all variables while leaving the program itself intact.
CLSCLS
Clears the display, leaving a blank screen.
CODEintegral functionCODE(<string>)
Returns the ZX80 character code of the first character of the string (0 for the empty string) - the machine's own codes, not ASCII. The inverse of CHR$.
CONTINUECONTINUE
Resumes a program that was halted by STOP or by BREAK.
DIMDIM <numvar>(<number>)
Declares a numeric array with the given number of elements. Array names are a single letter, and elements hold integers only.
FORFOR <numvar> = <number> TO <number>
Begins a counting loop. The control variable is a single letter, the bounds are integers, and there is no STEP, so the counter always increments by one.
GOSUBGOSUB <number>
Calls a subroutine at the given line number; a later RETURN comes back to the statement after the GOSUB.
GOTOGOTO <number>
Jumps to a line number. The target may be a computed expression, not just a literal line number.
IFIF <number> THEN <statement>
Runs the statement after THEN when the condition is true. Conditions use =, <, >, AND, OR and NOT; there is no ELSE.
INPUTINPUT <var>
Pauses the program to read a value typed at the keyboard into the given variable.
LETLET <var> = <expr>
Assigns a value to a variable. LET is mandatory on the ZX80 - assignment cannot be written without it.
LISTLIST [<line>]
Lists the program to the screen, optionally starting from a given line number.
LOADLOAD
Loads a program from cassette tape. As with SAVE, tapes are anonymous since the ZX80 has no named files.
NEWNEW
Erases the current program and all variables, leaving an empty workspace.
NEXTNEXT <numvar>
Marks the end of a FOR loop, incrementing the named control variable and looping back until its limit is passed.
NOTNOT <number>
Logical negation: yields 1 when its argument is 0 and 0 for any non-zero value. Useful for building comparisons the ZX80 lacks, e.g. NOT A<B for A>=B.
OR<number> OR <number>
Logical OR of two conditions, giving a non-zero (true) result when either operand is non-zero.
PEEKintegral functionPEEK(<addr>)
Returns the byte (0–255) stored at the given memory address.
POKEPOKE <addr>, <byte>
Writes a single byte (0–255) directly into memory at the given address.
PRINTPRINT [<expr>][;|,]…
Writes to the display. ZX80 BASIC is integer-only, so numeric values print without a fractional part; ; joins items tightly and , tabs to the next field.
RANDOMISERANDOMISE [<number>]
Seeds the random number generator that the ZX80 RND function draws on. RANDOMISE 0 (or with no argument) seeds it from the frame counter for an unpredictable start.
REMREM <comment>
Marks the rest of the line as a comment, which is ignored when the program runs.
RETURNRETURN
Returns from a subroutine, resuming execution at the statement after the matching GOSUB.
RNDintegral functionRND(<number>)
Returns a pseudo-random number. On the ZX80, RND takes an argument and must be written with parentheses (unlike the later ZX81). Seed the sequence with RANDOMISE.
RUNRUN [<line>]
Clears all variables and runs the program, optionally starting from a given line number.
SAVESAVE
Saves the current program to cassette tape. The ZX80 has no named files, so the dump is anonymous.
STOPSTOP
Halts the program, reporting where it stopped so it can be resumed with CONTINUE.
STR$integral functionSTR$(<number>)
Returns the number formatted as a string, exactly as PRINT would display it.
THENIF <number> THEN <statement>
Introduces the single statement run when the IF condition is true. The ZX80 has no ELSE and no multi-statement lines, so exactly one statement may follow.
TL$integral functionTL$(<string>)
Returns the "tail" of a string: everything after the first character (the ZX80 equivalent of MID$(a$, 2) on other machines).
TOFOR <numvar> = <number> TO <number>
Separates the start and end values of a FOR loop. Both bounds are integers, since ZX80 BASIC has no fractional numbers, and there is no STEP clause.
USRintegral functionUSR(<addr>)
Calls machine code at the given address and returns the value of the BC register pair on RET.
Argument notation

Anything in <angle brackets> is a value you supply; everything else is typed exactly as shown. [square brackets] mark an optional part, | separates alternatives, and … means the part before it can repeat. The arguments on this page are:

<number>
a numeric expression
<string>
a string expression
<expr>
a value of either type, where the keyword takes both
<byte>
a value from 0 to 255
<var>
a variable of either type
<numvar>
a numeric variable
<line>
a line number
<statement>
one BASIC statement
<comment>
free text, to the end of the line
<addr>
a memory address

Showing 47 of 47 keywords

Released under GNU GPL v3.0. Some ROM images are third-party copyrighted works, separate to this project, strictly for personal/educational purposes.