A Comparision of Keywords on the ZX80 and ZX Spectrum
Overview
The following is a list of keywords, operators and delimiters used on the ZX80 and ZX Spectrum. The ZX80 has many differences which make comparisons difficult but not impossible. For one thing, the ZX80 does not use floating-point arithmetic like the ZX Spectrum, instead it uses integer based arithmetic. This can make complex mathematics like trigonomety a bit tricky. Programs running under integer based BASIC may run faster than those running under floating-point BASIC, so the ZX80 may actually run some programs faster than the ZX Spectrum.
On the ZX Spectrum and ZX81 a single keyword entry system is used when entering programs into memory, in other words a keyword like PRINT is entered by pressing the P key and the whole keyword will be display without the need to enter the four other letters. On the 128K, +2, +3 and the QL keywords are entered one letter at a time. The ZX80 is unique in that it use a mixture of both. Most of the statements and functions are obtained by pressing a single key (or a single key shifted), but a few of these are typed in character by character. These are called the Integral Functions.
Microdrive commands have not been included as these are totally exclusive to the ZX Spectrum and cannot translated to ZX80 BASIC.
Reference to the ZX80 on this page refers to the ZX80 with 4K ROM. When the ZX80 is installed with an 8K ROM it becomes a ZX81 (mostly).
Commands
Keyword
Meaning
Comments
CLEAR
CLEAR (ZX80 & ZX Spectrum)
CLEAR n (ZX Spectrum)
Result: Clears the screen, deletes all variables, resets PLOT and PRINT positions and clears the GOSUB stack. If a number is specified then RAMTOP is lowered to n.
CLEAR on the ZX80 only deletes all variables.
CONTINUE
CONTINUE
Result: After error report 9 (STOP Statement) or report L (BREAK into program) CONTINUE will execute the next line after the error occurred.
CONTINUE is shortened to CONT on the ZX80 and ZX Spectrum keyboards. Error L on the ZX Spectrum is equivelent to error 0 on the ZX80.
LIST
LIST
LIST n
Result: Display program listing from line n or line 0 is no line number specified.
ZX80 will only display one page before stopping and a new LIST statement with the next line number after the last one displayed must be issued. The ZX Spectrum will display the message 'scroll?' if the listing will not fit onto one page. Pressing 'y' will continue the listing.
LLIST
LLIST
LLIST n
Result: Send program listing from line n (or line 0 is no line number specified) to the ZX Printer.
It is not possible to use an unmodified ZX80 with the ZX Printer.
LOAD
LOAD (ZX80 only)
LOAD f (ZX Spectrum)
LOAD f DATA () (ZX Spectrum only)
LOAD f DATA $() (ZX Spectrum only)
LOAD f CODE m,n (ZX Spectrum only)
LOAD f CODE m (ZX Spectrum only)
LOAD f CODE (ZX Spectrum only)
LOAD f SCREEN$ (ZX Spectrum only)
Result: Load program (or code) f from tape into memory.
LOAD is a single comand on the ZX80. ZX Spectrum has extra options to load dimensional arrays, code direct to memory or a screen to the display file.
MERGE
MERGE f
Result: Merge program f with that already in memory overwriting duplicate program lines.
Not on the ZX80.
NEW
NEW
Result: Deletes program and variables and memory up to and including the address held in the system variable RAMTOP.
Similar on both micros. The ZX Spectrum also preserves the system variables UDG, P-RAMT, RASP and PIP.
RUN
RUN
RUN n
Result: Perform CLEAR and GO TO line n (or line 0 if n not specified).
Same on both micros.
SAVE
SAVE (ZX80)
SAVE f (ZX Spectrum)
SAVE f LINE m (ZX Spectrum)
SAVE f DATA () (ZX Spectrum)
SAVE f DATA $() (ZX Spectrum)
SAVE f CODE m,n (ZX Spectrum)
SAVE f SCREEN$ (ZX Spectrum)
Result: Save program f to tape from memory.
SAVE on the ZX80 will save a program, variables and system variables to tape. ZX Spectrum has extra options to save dimensional arrays, code from memory or the display file.
On the ZX Spectrum the item LINE m will RUN a program from line m once loaded. ZX Spectrum filenames only allow up to 10 characters, the ZX80 saves with no filename.
VERIFY
VERIFY f
VERIFY f DATA ()
VERIFY f DATA $()
VERIFY f CODE m,n
VERIFY f CODE m
VERIFY f CODE
VERIFY f SCREEN$*
*This command will be accepted by the Spectrum but taped SCREEN$ code will fail verification.
Result: Compared program f from tape with that in memory. Error R if verify fails.
Not available on ZX80.
Statements
Keyword
Meaning
Comments
AT
AT x,y
Result: Changes PRINT or INPUT position to x,y.
Not on the ZX80.
BEEP
BEEP x,y
Result: Sound emitted for x seconds at pitch y.
The ZX80 has no sound facility so BEEP in not possible on that micro.
BORDER
BORDER m
Result: Changes screen border colour to m.
It is not possible to change the border on the ZX80.
The brightness of the screen cannot be changed on the ZX80.
CIRCLE
CIRCLE x,y,z
Result: Draws a circle of radius z at position x,y.
High resolution graphics are not possible on the ZX80.
CLS
CLS
Result: Clears the screen.
Same result on both micros.
COPY
COPY
Result: Sends the contents of the screen to the ZX Printer.
It is not possible to use an unmodified ZX80 with the ZX Printer.
DATA
DATA e1,e2,e3, ...
Result: Stores data in a list.
Not on the ZX80. Dimensional arrays and LET should be used instead.
DEF FN
DEF FN α(α1, αk)=e
Result: Defines a function. α and α1 to αk can be a single letter or single letter followed by $ for a string argument.
Not on the ZX80.
DIM
DIM α(n1) (ZX80)
DIM α(n1,...,nk) (ZX Spectrum)
DIM α$(n1,...,nk) (ZX Spectrum)
Result: Sets up an array of numbers or characters with k dimensions. For numeric arrays all values are set to zero. In the case of a string array all values are set to SPACE (CHR$ 32).
ZX80 arrays are numeric integer, 1-dimensional only and have a base of 0, unlike the ZX81 and ZX Spectrum which have a base of 1, so the code for an array of 10 numbers on the ZX80 would be
DIM A(9)
whereas on the ZX81 and ZX Spectrum it would be
DIM A(10)
String arrays are not allowed on the ZX80.
DRAW
DRAW x,y
DRAW x,y,z
Result: DRAW a high resolution line from the currect PLOT position moving x horizontally and y vertically rotating through angle z if third parameter is specified.
High resolution graphics are not possible on the ZX80.
FLASH
Result: If n is set to 1 flash effect is turned on. If n is set to zero then flash effect is turned off.
As the standard ZX80 is not capable of animated text or graphics it is not possible to recreate the FLASH effect on this micro.
GO SUB
GO SUB n
Result: Stack GO SUB line number and branch (GO TO) line n.
Same on both micros. The ZX80 keyboard spells GO SUB as 'GOSUB'. The ZX Spectrum manual is inconsistent with the spelling of GO SUB, using both GO SUB and GOSUB!
GO TO
GO TO n
Result: Branch or GO TO line n.
Again, like above the same on both micros. The ZX80 keyboard spells GO TO as 'GOTO'.
INK
INK n
Result: Sets foreground colour of chracters to be printed. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
As the ZX80 is a monochrome computer this statement is only available on the Spectrum.
INPUT
INPUT v (ZX80 & ZX Spectrum)
INPUT v1,v2,v3... (ZX Spectrum only)
INPUT LINE α$ (ZX Spectrum only)
Result: Computer waits for input of an expression then passes the value of this to the variable v.
The ZX Spectrum command allows for multiple variables to be input on the same INPUT statement i.e. INPUT v1,v2,v3... ZX Spectrum also allows PRINT items to be used such as INK and PAPER. INPUT LINE v on the Spectrum strips the quotes on the input line and waits for a string to be input.
INVERSE
INVERSE n
Result: If n=0 characters are printed in normal video. If n=1 characters are printed in inverse video.
The INVERSE statement is not implemented on the ZX80 although inverse characters are available in the ZX80 character set.
LET
LET v=e
Result: Assign the value e to the variable v.
Same on both micros.
LPRINT
LPRINT ...
Result: Send a line of items to be printed to the ZX Printer.
It is not possible to use an unmodified ZX80 with the ZX Printer.
OUT
OUT m,n
Result: Outputs byte n to port m.
Not on the ZX80 but can be accessed from machine code.
OVER
OVER n
Result: If n=0 characters obliterate those already at that position. If n=1 characters are merged with those already at that position.
This is a high resolution display statement and is not available on the ZX80. If n=1 OVER essentially performs an eXclusive OR with the old and new pixels. If both pixels are off (0) they will stay off (0). If the old pixel if off (0) and the new one is on (1) the displayed pixel will be on (1). If both old and new pixels are on (1) the diplayed pixel will be (0).
PAPER
PAPER n
Result: Sets background colour of chracters to be printed. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
As the ZX80 is a monochrome computer this statement is only available on the Spectrum.
PAUSE
PAUSE n
Result: Stop program execution for n*1/50seconds or until a key is pressed.
On the ZX Spectrum PAUSE 0 is not timed but lasts until a key is pressed.
Not on the ZX80 although a PAUSE can be simulated with a FOR...NEXT loop.
PLOT
Type: Display statement
PLOT c;m,n
Result: Sets pixel ink at position m,n subject to c (INK/PAPER/OVER/INVERSE).
High resolution graphics are not available on the ZX80.
POKE
Type: Memory statement
POKE m,n
Result: Load byte n into memory address m.
Same on both micros.
PRINT
Type: Display statement
PRINT ...
Result: Send a series of items to the display subject to control characters and AT/TAB (and colour/INVERSE/FLASH/OVER on the ZX Spectrum).
Similar on both micros with some exceptions. ZX Spectrum can also PRINT to an I/O device using streams and channels.
RANDOMISE or RANDOMIZE
Type: Numeric statement
RANDOMISE (ZX80)
RANDOMISE n (ZX80)
RANDOMIZE (ZX Spectrum)
RANDOMIZE n (ZX Spectrum)
Result: Sets system variable SEED to n which will be the basis for pseudo-random numbers (RND).
Same on both micros (except spelling - ZX80 uses the english spelling, ZX Spectrum use the american spelling). ZX80/ZX Spectrum keyboards shows shortened RAND and not RANDOMISE/RANDOMIZE.
READ
Type: Variable assignment statement
READ e1,e2,e3, ...
Result: Read from DATA statement and pass to a variable or variables e1,e2,e3, ..
Not on the ZX80. Dimensional arrays and LET should be used instead.
REM
Type: Programming statement
REM ...
Result: None, display comment in program listing.
Same on both micros. ZX80 micros can utilise REM statements to store machine code and although the ZX Spectrum is also capable of this it is not used as much as it is easier to place machine code above RAMTOP.
RESTORE
Type: Statement used with READ/DATA
RESTORE
RESTORE n
Result: Restores DATA pointer to line n or first line of program if n is not specified. READ will starting reading from there.
Not on the ZX80. Dimensional arrays and LET should be used instead.
RETURN
Type: Branching statement
RETURN
Result: Take line number off GO SUB stack and GO TO the line after that line number.
Same on both micros.
STOP
Type: Program execution statement
STOP
Result: Stops program execution with Report 9.
Same on both micros.
TAB
Type: Display statement
TAB x
Result: Changes PRINT, LPRINT or INPUT tab position to x.
Not on the ZX80 although automatic tabs (, comma) 8 characters across could be used.
Returns: Single character from position x in the character set.
Although the CHR$ function performs the same task on both computers the end result will be different as the Spectrum's character set
is based on the ASCII code, while the ZX80's is unique.
On the ZX80 CHR$ is an integral function.
CODE
Type: String function
CODE(α$) (ZX80)
CODE α$ (ZX Spectrum)
Returns: Numeric value (between 0 and 255) representing the position in the character set of α$. This is the inverse of the CHR$ function.
Although the CODE function performs the same task on both computers, just like CHR$ above, the end result will also be different.
On the ZX80 CODE is an integral function.
COS
Type: Trigonometric function
COS x
Returns: Cosine of x in radians.
Trigonometric functions are not available on the ZX80.
EXP
Type: Mathematical function
EXP x
Returns: Numeric value for the function ex where e=2.7182818...
Not on the ZX80.
FN
Type: User defined function
FN α(α1, αk)
Result: Calls a function. α and α1 to αk can be a single letter or single letter followed by $ for a string argument.
Not on the ZX80.
See also DEF FN.
INKEY$
Type: String function
INKEY$ has no operands.
Returns: Single character from a keypress.
Typical usage would be
PRINT INKEY$
LET A$=INKEY$ or
10 IF INKEY$="" THEN GO TO 10
Not on the ZX80.
IN
Type: Numeric function
IN m
Returns: numeric value between 0 and 255 for the port m.
Not on the ZX80 but can be accessed from machine code.
INT
Type: Mathematical function
INT x
Returns: x rounded down to the nearest integer.
Not required on the ZX80 as this micro is integer based anyway.
When converting programs from the ZX80 to the ZX Spectrum INT should be placed in front of any division operator, for example:
PRINT 7/5
would yield 1 on the ZX80 but 1.4 on the ZX Spectrum. We must use the following code to give the correct result on the Spectrum.
PRINT INT(7/5)
[Note] On the ZX Spectrum when INT -65536 is performed the wrong result is given as -1.
Returns: numeric value for the natural logarithm of x.
Not on the ZX80.
PEEK
Type: Memory function
PEEK(m) (ZX80)
PEEK m (ZX Spectrum)
Returns: numeric value (0 to 255) stored at memory location m.
Same on both micros.
On the ZX80 PEEK is an integral function.
PI
Type: Constant
PI has no operands.
Returns: 3.1415927 (π) Ratio of circumference of a circle to its diameter
Typical usage might be:
LET R=C/(2*PI)
Not on the ZX80
[Note] PI is stored on the ZX Spectrum as 10 digits but will only display 8 digits.
POINT
Type: Display function
POINT (x,y)
Returns: 0 or 1 for the screen location x,y.
This is a high resolution function and is not available on the ZX80.
RND
Type: Mathematical function
RND(n) (ZX80)
RND (ZX Spectrum)
Returns (ZX80)
A pseudo-random number in the range: 1 to n if n>0 1 to 32767 or -32768 to n-1 if n<0. 1 if n=0
Returns (ZX Spectrum)
A pseudo-random number between 0 and 1 is generated, no operands are required.
An example of usage would be
LET X=RND(42) (ZX80)
LET X=INT(RND*42)+1 (ZX Spectrum)
Although both micros both produce a pseudo-random number the ZX80 with generate an integer between -32768 and 32767 and the ZX Spectrum will generate a decimal fraction between 0 and 1.
SCREEN$
Type: Display function
SCREEN$ (x,y)
Returns: character displayed at location x,y.
Not on the ZX80.
SGN
Type: Mathematical function
SGN x
Returns: signum (or sign) of x, for instance -1 if x<0, 0 if x=0 or 1 if x>1.
Not on the ZX80 but can be simulated with the following code:
Result: string comprising of the numeric value of x.
Same for both micros.
On the ZX80 STR$ is an integral function.
TAN
Type: Trigonometric function
TAN x
Returns: Tangent of x in radians.
Trigonometric functions are not available on the ZX80.
TL$
Type: String function
TL$(α$)
Returns: α$ less its first character.
Exclusive to the ZX80 but is easily implemented on the ZX Spectrum or ZX81 with:
α$(2 TO)
On the ZX80 TL$ is an integral function.
USR
Type: System function
USR(x) (ZX80)
USR x (ZX Spectrum)
Returns: contents of the hl register pair (ZX80) or bc register pair (ZX Spectrum) after calling machine code at memory location x.
Same for both micros except the different register pairs returned.
On the ZX80 USR is an integral function.
USR
Type: Memory function
USR α$
Returns: location in memory of user defined graphic α$.
The function USR (with string argument) is completely different to USR (numeric argument) above and is used to find the location of a particular user-defined graphic. Since the ZX80 has no UDG's this function is not available on the ZX80.
VAL
Type: String function
VAL α$
Returns: numeric value evaluated from the string α$.
There does not appear to be a simple way to simulate this function in ZX80 BASIC.
Operators
Keyword
Meaning
Comments
-
Unary Minus/Negation
Type: Mathematical operator
-x
Result: negates x
Same on both micros.
-
Binary Minus/Subtraction
Type: Mathematical operator
x-y
Result: a numeric value resulting from y being subtracted from x.
Same on both micros.
+
Addition
Type: Mathematical operator
x+y
Result: a numeric value resulting from y being added to x.
Same on both micros.
+
String concatenation
Type: String operator
α$+β$
Result: concatenates (joins together) string α with string β to form a new string.
String concatenation is not possible on the ZX80.
/
Division
Type: Mathematical operator
x/y
Result: a numeric value resulting from x being divided by y.
On the ZX80 this is always integer division.
See also INT.
*
Multiplication
Type: Mathematical operator
x*y
Result: a numeric value resulting from x being multiplied by y.
Same on both micros.
** or ↑
Raise to the power of
Type: Mathematical operator
x**y (ZX80)
x↑y (ZX Spectrum)
Result: a numeric value resulting from x being raised to the power of y.
Same meaning on both micros but the ZX80 uses a double asterisk ** whereas the ZX Spectrum uses an up arrow ↑.
If y is negative on the ZX80 error 6 (arithmetic overflow) will occur.
<
Less than
Type: Comparison operator
x<y
Where x and y can be either numeric or strings but cannot be mixed.
Result: -1 if x<y otherwise 0. (ZX80)
Result: 1 if x<y otherwise 0. (ZX Spectrum)
A true result on the ZX80 will give -1. Placing ABS around the equation like so
ABS(x<y)
will make the result +1 like the ZX Spectrum.
Conversely, on the Spectrum multiply the result by -1 to give the same result as the ZX80:
-1*(x<y)
>
Greater than
Type: Comparison operator
x>y
Where x and y can be either numeric or strings but cannot be mixed.
Result: -1 if x>y otherwise 0. (ZX80)
Result: 1 if x>y otherwise 0. (ZX Spectrum)
A true result on the ZX80 will give -1. Placing ABS around the equation like so
ABS(x>y)
will make the result +1 like the ZX Spectrum.
Conversely, on the Spectrum multiply the result by -1 to give the same result as the ZX80:
-1*(x>y)
<=
Less than or equal to
Type: Comparison operator
x<=y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x≤y otherwise 0.
Not on the ZX80.
Use the following code instead:
NOT (x>y)
Result will be -1 if true.
>=
Greater than or equal to
Type: Comparison operator
x>=y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x≥y otherwise 0.
Not on the ZX80.
Use the following code instead:
NOT (x<y)
Result will be -1 if true.
=
Is equal to
Type: Comparison operator
x=y
Where x and y can be either numeric or strings but cannot be mixed.
Result: -1 if x=y otherwise 0. (ZX80)
Result: 1 if x=y otherwise 0. (ZX Spectrum)
A true result on the ZX80 will give -1. Placing ABS around the equation like so
ABS(x=y)
will make the result +1 like the ZX Spectrum.
Conversely, on the Spectrum multiply the result by -1 to give the same result as the ZX80:
-1*(x=y)
<>
Is not equal to
Type: Comparison operator
x<>y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x≠y otherwise 0.
Not on the ZX80.
Use the following code instead:
NOT (x=y)
Result will be -1 if true.
AND
Type: Logical operator
x AND y
Where x and y are always numeric. (ZX80)
Where x is a number or a string, and y is always numeric. (ZX Spectrum)
Returns: x if y is true (non-zero) or 0 if y is false (zero).
Strings cannot be tested directly with AND on the ZX80.
OR
Type: Logical operator
x OR y
Returns: 1 if x or y≠0, value of x if b=0.
Same on both micros
NOT
Type: Logical operator
NOT x
Returns: zero if x≠0, 1 if x=0
Same on both
TO
Type: String operator
v$(x TO y)
v$(x TO)
v$(TO y)
v$( TO ) * This works but is pointless!
Returns: Slices string v from x to y, x to end of string or start of string to y. TO without any operands will return a string unsliced (see fourth example).
Apart from TL$ the ZX80 has no string slicing capabilities.
Result: separates items within a PRINT, LPRINT (ZX Spectrum only) or INPUT (ZX Spectrum only) statement.
ZX80 cannot use a semi-colon as a delimiter with an INPUT statement.
'
Apostrophe
Type: PRINT delimiter
PRINT ' (ZX80 & ZX Spectrum)
LPRINT ' (ZX Spectrum)
INPUT ' (ZX Spectrum)
Result: Moves the PRINT or LPRINT position down a line.
ZX80 cannot use an apostrophe as a delimiter in an INPUT statement.
,
Comma
Type: PRINT delimiter
PRINT , (ZX80 & ZX Spectrum)
LPRINT , (ZX Spectrum)
INPUT , (ZX Spectrum)
Result: Moves the PRINT position across the screen (or printer) or to the start of the next line if PRINT position is greater or equal to the last tab position.
ZX80 cannot use a comma as a delimiter in an INPUT statement.
Automatic tabs are 8 characters across on the ZX80 and 16 on the ZX Spectrum or ZX Printer.
,
Comma
Type: Operand delimiter
Separates operands within a statement.
Examples:
POKE x,y (ZX80 & ZX Spectrum)
ATTR (x,y) (ZX Spectrum)
Result: Separates operands within a statement.
ZX80 cannot use a comma as a delimiter in an INPUT statement.
#
Hash
Type: Stream escape
PRINT #m
LPRINT #m
INPUT #m
Result: Output to stream m.
Only on the ZX Spectrum.
:
Colon
Type: Statement delimiter
s1 : s2 : s3 ...
Result: Allows more than one statement per line number to be entered.
Only on the ZX Spectrum.
"
Single quotation marks
Type: String encloser
α$="Ford Prefect" (ZX80 & ZX Spectrum)
PRINT "Ford Prefect" (ZX80 & ZX Spectrum)
LPRINT "Ford Prefect" (ZX Spectrum)
INPUT "Ford Prefect" (ZX Spectrum)
Result: Encloses text within a string. Encloses text with a PRINT, LPRINT or INPUT (ZX Spectrum only) statement.
ZX80 cannot use a single quotes within an INPUT statement.
ZX Spectrum can store a single quote within a set of quotation marks like so
""""
The ZX80 cannot place a quote within a string. If there was some way of adding a character to a string then it may be possible to use
CHR$(212)
212 is the ZX80 code for a single quote.
The ZX80 can use this in a PRINT statement though:
PRINT CHR$(212);"DOLPHIN";CHR$(212)
Will produce:"DOLPHIN"
Nomenclature
This list uses the same letters to represent variables, expressions and sequences etc. as the ZX80 and ZX Spectrum BASIC manuals.
α,β represents a single letter
v represents a variable
x,y,z represents numerical expressions
m,n represents numerical expressions rounded to the nearest integer
b represents a 16 bit binary number
e represents an expression
f represents a string valued expression
s represents a sequence of statement separated by colons :
c represents a sequence of colour items, each terminated by commas , or semi-colons ; A color item has the form of a PAPER, INK, FLASH, BRIGHT, INVERSE or OVER statement.
A note on brackets. Where brackets are shown they are mandatory, this includes the ZX80 integral functions and ZX Spectrum 'two parameter' functions and user defined functions.
References
A Course in BASIC Programming - ZX80 Operating Manual, Science of Cambridge / Sinclair (publisher)
Sinclair ZX Spectrum BASIC Programming, Steven Vickers (author), Robin Bradbeer (editor)