A Comparision of Keywords on the Acorn Atom and the ZX Spectrum
Overview
The following is a list of keywords, operators and delimiters used on the Acorn Atom microcomputer and the ZX Spectrum.
Released in 1980, two years before the Spectrum, the Acorn Atom used a version of BASIC based on an earlier computer built by Acorn called the System 3. Atom BASIC is quite different to Sinclair BASIC, for instance, semi-colons are used to separate statements instead of colons and one-character labels may be used for GOTO and GOSUB statements. Other differences include the way the Atom stores variables and handles strings, the use of indirection operators, and its use of abbreviations.
The Atom has multiple screen modes with the highest being the same resolution (albeit monochrome) as the Spectrum (256 x 192).
An unexpanded Acorn Atom is equipped only with integer BASIC, however an expansion ROM was available which gave the Atom floating-point arithmetic and a host of new keywords. In the table below, the term Acorn Atom FP-ROM is used where floating-point keywords are listed, otherwise just Acorn Atom is used for integer Acorn Atom BASIC.
Commands
Keyword
Meaning
Comments
*CAT
*CAT (Acorn Atom)
Result (Acorn Atom): Displays a catalogue of files on a tape.
Not on the ZX Spectrum, but short machine code routines exist which will do the same thing as *CAT.
See also LOAD / *LOAD, MERGE, SAVE / *SAVE, VERIFY
CLEAR
CLEAR [n] (ZX Spectrum)
Result (ZX Spectrum): 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.
On the Atom CLEAR works more like CLS.
CONTINUE
CONTINUE (ZX Spectrum)
After BREAK* is pressed CONTINUE will execute the next line after the error occurred.
*The reportL (BREAK into program) occurs on the ZX Spectrum when BREAK is pressed whilst a program is running.
Not on the Acorn Atom.
The ZX Spectrum keyboard shows CONTINUE as CONT.
LINK
LINK n
Result (Acorn Atom): Calls a machine code subroutine at address n.
Not on the Spectrum, use USR to call a machine code subroutine instead.
See also USR.
LIST
LIST (Acorn Atom and ZX Spectrum)
Result: Display complete program listing.
LIST n (ZX Spectrum)
Result: Display program listing from line n or line 0 where no line number specified.
LIST n (Acorn Atom)
Result: Display single program line n.
LIST [m],[n] (Acorn Atom)
Result: Display program listing from line m (optional) to line n (optional) inclusive.
See also LLIST
LLIST
LLIST [n] (ZX Spectrum)
Result: Print the program listing from line n or line 0 where no line number specified.
The Acorn Atom uses control codes to send output to the printer.
See also LIST
LOAD
(Acorn Atom & ZX Spectrum)
*LOAD
(Acorn Atom)
LOAD "" (Acorn Atom & ZX Spectrum)
Result: Load the first program encountered on cassette. Double quotes may be replaced by a string variable as long as it is a null string.
LOAD f (Acorn Atom & ZX Spectrum)
Result: Load program f.
Note: f may be a string variable, in which case it will be something like a$ on the Spectrum but just a on the Atom (not $a).
LOAD f DATA () (ZX Spectrum only)
Result: Load array f from cassette into the variables area of memory.
LOAD f CODE [m[,n]] (ZX Spectrum)
*LOAD f m (Acorn Atom)
Result: Load data from cassette into the memory location m (Acorn Atom & ZX Spectrum) and of length n (ZX Spectrum only).
LOAD f SCREEN$ (ZX Spectrum only)
Result: Load screen data into from tape directly into the display file (same as:LOAD f CODE 16384,6192 )
See also *CAT, MERGE, SAVE / *SAVE, VERIFY.
MERGE (ZX Spectrum)
MERGE f (ZX Spectrum)
Result: Merge program f with that already in memory overwriting duplicate program lines.
Not on the Acorn Atom.
NEW
NEW
Result (Acorn Atom): Inserts an 'end of text' marker at the start of the text (program) area, and changes the value of TOP.
Result (ZX Spectrum): Deletes program and variables and memory up to and including the address held in the system variable RAMTOP.
Acorn Atom programs made inaccessible by NEW may be recalled with OLD. On the ZX Spectrum NEW preserves the system variables UDG, P-RAMT, RASP and PIP.
See also OLD.
OLD
OLD
Result (Acorn Atom): Recovers text program (reverses NEW and recovers a previously 'deleted' program).
Not on the Spectrum, so be careful!
See also OLD.
RUN
RUN (Acorn Atom)
Result (Acorn Atom): Execute program from the first line.
RUN [n] (ZX Spectrum)
Result (ZX Spectrum): Perform CLEAR and GO TO line n (or line 0 if n not specified).
Similar on both micros.
RUN on the ZX Spectrum clears the screen.
If line n does not exist on the Spectrum, the next valid line number will be executed.
SAVE
SAVE f [LINE m] (ZX Spectrum)
Result: Save program f to tape. If LINE is specified then RUN program from line m once loaded (ZX Spectrum)
SAVE f (Acorn Atom)
Result: Save program f to tape. (Acorn Atom). SAVE f DATA α[$]() (ZX Spectrum)
Result: Save array α to tape.
*SAVE f m n address (Acorn Atom)
Result: Save code from memory to tape starting at address m and ending at address n, with an optional execution address.
SAVE f CODE m,n (ZX Spectrum)
Result: Save code from memory to tape starting at address m with a length of n bytes. (ZX Spectrum)
SAVE f SCREEN$ (ZX Spectrum)
Result: Save display file with filename f to tape (same as SAVE f CODE 16384,6192).
See also *CAT, LOAD / *LOAD, MERGE, VERIFY.
VERIFY
VERIFY f (ZX Spectrum)
VERIFY f DATA α[$]() (ZX Spectrum)
VERIFY f CODE [m[,n]] (ZX Spectrum)
VERIFY f SCREEN$* (ZX Spectrum)
*This command will be accepted by the Spectrum but taped SCREEN$ code will fail verification.
Result (ZX Spectrum): Compares program/array/code, with filename f, from tape with that in memory. Error R if verify fails.
Not on the Acorn Atom.
Statements
Keyword
Meaning
Comments
AT (ZX Spectrum)
PRINT AT x,y; (ZX Spectrum)
INPUT AT x,y; (ZX Spectrum)
Result: Changes PRINT or INPUT position to x,y.
On the Atom there is not an equivalent to AT. The only way to display at a specific location on-screen is the directly alter the memory location which relates to the specific chracter you are trying to display (see example below).
A=&8000+Y*32+X
?A=c
where A is the location in display memory, X and Y are the screen coordinates, and c is the code of the character to display. &8000 is the address in hexadecimal which points to the start of display memory.
See also PRINT.
BEEP
BEEP x,y (ZX Spectrum)
Result: Sound emitted for x seconds at pitch y.
The Acorn Atom can only emit a beep of one tone. More complex sounds can only be achieved through the use of machine code.
BORDER
BORDER m
Result: Changes screen border colour to m.
Although it is not possible to directly change the border colour on an extended Acorn Atom, it is possible to change the whole background colour (including 'border' area) in graphics mode, so a workaround my be possible.
BRIGHT
BRIGHT n
Result: When n=1 permanent brightness is turned on. When n=0 permanent brightness is off.
keywordBRIGHT n
Result: When n=1 temporary brightness is turned on. When n=0 temporary brightness is off.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When BRIGHT is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The brightness of the screen cannot be changed on the Acorn Atom.
CIRCLE
CIRCLE [c;]x,y,z (ZX Spectrum)
Result: Draws a circle subject to colour items (c), of radius z at position x,y.
Not on the Atom, other methods to draw a circle must be used.
CLEAR
(Acorn Atom statement)
CLEAR n (Acorn Atom)
Result: Clears the graphics screen (where n is an integer between 0 and 4).
CLEAR 0 : Screen is 64*48 (semi-graphics mode)
CLEAR 1 : Screen is 128*64
CLEAR 2 : Screen is 128*96
CLEAR 3 : Screen is 128*192
CLEAR 4 : Screen is 256*192
The ZX Spectrum only has one graphics mode so just use CLS as a direct replacement for CLEAR.
See also CLS
CLOSE #
CLOSE #stream_number (ZX Spectrum)
Result: Close device / stream.
Not on the Acorn Atom.
CLS
CLS (ZX Spectrum)
Result: Clears the screen and sets the current background colour and foregraound (PAPER and INK). On the Spectrum the PRINT and PLOT positions are both set to 0,0.
For the Atom see CLEAR (statement).
COLOUR
COLOUR n (Acorn Atom FP-ROM + Colour Extension Board)
Result: Changes 'background' colour to n.
COLOUR 0 : Green
COLOUR 1 : Yellow
COLOUR 2 : Blue
COLOUR 3 : Red
The 'background' colour, as referred to in the Acorn Atom manual, is actually more like INK on the Spectrum.
To simulate a monochrome Acorn Atom screen on the Spectrum, first set the PAPER to 4 (green) and clear the screen (CLS), then COLOUR n would be replaced with INK n.
An Acorn Atom with a floating-point extension ROM, but without a colour extension board, will accept the COLOUR statement but will not display colour.
See also: INK, PAPER.
COPY
COPY (ZX Spectrum)
Result: Sends the contents of the screen to the ZX Printer.
Not on the Acorn Atom.
See also LLIST, LPRINT.
DATA
DATA e1,e2,e3, ...
Result: Stores data in a list.
Not on the Acorn Atom but routines to simulate DATA, READ, and RESTORE can be found on this link and searching for chapter 8.7 "Reading Text".
See also READ, RESTORE.
DEF FN
DEF FN α([α1[,...,αk]])=e (ZX Spectrum)
Result: Defines a function. α and α1 to αk can be a single letter or single letter followed by $ for a string argument.
Definable functions are not available on the Acorn Atom.
DIM
(Acorn Atom & ZX Spectrum)
FDIM
(Acorn Atom FP-ROM)
DIM αα(n)[,more items...] (Acorn Atom)
Result: Sets up a numeric 2-word (4-byte) one-dimension array where αα is the variable name and n is the highest subscript (if n=5 then 6 subscripts for zero to 5 will be created).
Note: αα is the same letter twice, for example: AA or ZZ.
DIM α(n)[,more items...] (Acorn Atom)
Result: Sets up a numeric one-byte one-dimension array where α is the variable name and n is the highest subscript (if n=5 then 6 subscripts for zero to 5 will be created).
DIM %αα(n)[,more items...] (Acorn Atom FP-ROM)
Result: Sets up a floating-point array of n elements, where αα is the variable name and n is the highest subscript (if n=5 then 6 subscripts for zero to 5 will be created).
Note: αα is the same letter twice, for example: AA or ZZ.
DIM $α(n)[,more items...] (Acorn Atom)
Result: Sets up a one-dimension array, suitable for string handling, where $α is the variable name and n is the highest subscript (if n=5 then 6 subscripts for zero to 5 will be created).
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).
The Atom can only handle single dimension arrays, these arrays have a base of zero rather than a base of 1 like the Spectrum.
Strings on the Atom must be declared by using DIM.
See also: LET.
DRAW
DRAW x,y (Acorn Atom)
Result: DRAW a high resolution line from the current hi-res position to coordinate x,y.
DRAW [c;]x,y[,z] (ZX Spectrum)
Result: DRAW a high resolution line from the current PLOT position moving x horizontally and y vertically rotating through angle z if third parameter is specified.
DRAW on the Spectrum uses the relative coordinate system, whilst the Atom uses the absolute coordinate system.
END
END (Acorn Atom)
Result: Terminates program and returns control to the user and resets the value of TOP to point to the first free byte after the program text (memory location where program is stored).
Not on the Spectrum. STOP may be used instead.
For a similar approach to END for ending a program on the Spectrum try redirecting the program flow to line 9999 and include a STOP statement on that line. CONTINUE will not work after the STOP in line 9999.
See also STOP, CONTINUE.
FDIM
See DIM
FIF
See IF (compund statement)
FINPUT
See INPUT
FLASH
FLASH n (ZX Spectrum)
Result: If n is set to 1 permanent flash effect is turned on. If n is set to zero then permanent flash effect is turned off.
keywordFLASH n (ZX Spectrum)
Result: If n is set to 1 temporary flash effect is turned on. If n is set to zero then temporary flash effect is turned off.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When FLASH is applied to the keyword LPRINT there will be no effect, obviously.
Not on the Atom, but a subroutine to alternately display normal and inverted text could be a substitute for FLASH.
GOSUB or GO SUB
GOSUB n¦label (Acorn Atom)
GO SUB n (ZX Spectrum)
Result: Stack current line number and branch to (GO TO) line n (Acorn Atom and ZX Spectrum) or to label (Acorn Atom only).
Same result all round with the exception of the spelling, GO SUB with a space for the Spectrum and without (GOSUB) for the Atom.
Also, the Acorn Atom may use a label in the form of a single lowercase letter.
The ZX Spectrum manual is inconsistent with the spelling of GO SUB, using both GO SUB and GOSUB!
GOSUBlabel can be simulated on the Spectrum by using a named variable i.e.
LET m=9000
GO SUB m
See also: GOTO / GO TO, RETURN.
GOTO or GO TO
GOTO n¦label (Acorn Atom)
GO TO n (ZX Spectrum)
Result: Branch to (GO TO) line n (Acorn Atom and ZX Spectrum) or to label (Acorn Atom only).
Same result all round with the exception of the spelling, GO TO with a space for the Spectrum and without (GOTO) for the Atom.
Also, the Acorn Atom may use a label in the form of a single lowercase letter.
The ZX Spectrum manual is inconsistent with the spelling of GO TO, using both GO TO and GOTO!
GO TOlabel can be simulated on the Spectrum by using a named variable i.e.
LET m=9000
GO TO m
See also: GOSUB / GO SUB.
INK
INK n (ZX Spectrum)
Result (ZX Spectrum): Sets permanent foreground colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
If CLS if performed then the INK colour will be set to n for the whole screen.
keyword INK n; (ZX Spectrum only)
Result: Sets temporary foreground colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When INK is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The way the Acorn Atom handles colours is quite different to the ZX Spectrum. The only statement the Atom has to change the colours on the screen is the COLOUR statement.
COLOUR changes the 'background' colour which on the Spectrum would be the INK (not PAPER as would be expected). There is no PAPER equivalent on the Atom.
See also: COLOUR, PAPER.
INPUT
(Acorn Atom & ZX Spectrum)
FINPUT
(Acorn Atom FP-ROM)
INPUT v1[,v2,v3...] (Acorn Atom, and ZX Spectrum)
FINPUT %v1[,%v2,%v3...] (Acorn Atom FP-ROM)
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 allows PRINT items to be used such as INK and PAPER.
INPUT LINE α$ on the Spectrum strips the quotes on the input line and waits for a string to be input.
On the Atom, data is input from the last cursor position.
Note for the Atom Floating-Point ROM: Same as INPUT, but does not allow strings.
INVERSE
INVERSE n
Result: Turns permanent inverse video effect on when n=1 or off when n=0.
keywordINVERSE n
Result: Turns temporary inverse video effect on when n=1 or off when n=0.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements.
The INVERSE statement is not available on the Atom although inverse characters can be displayed by adding 32 to the ASCII character value i.e. character 'A' has the ASCII value of 65, adding 32 gives 97 which relates to an inverse video 'A'.
LET (Acorn Atom & ZX Spectrum)
L. (Acorn Atom abbreviation)
[LET] [$]v=e (Acorn Atom)
[L.] [$]v=e (Acorn Atom abbreviation)
LET v=e (ZX Spectrum)
Result: Assign the value e to the variable v.
LET is optional on the Atom and may be omitted.
Note: $ (dollar-sign) prefixes string identifiers on the Atom ($v), whereas on the Spectrum $ is a suffix to the identifier i.e. v$. v on the ZX Spectrum is meant to indicate all variables, string or otherwise, but for the Acorn Atom I give [$]v for clarity as this micro handles string identifiers differently for various statements according to context, and some statements will not require $ as a prefix to a string variable.
See also: DIM.
LINK
LINK m (Acorn Atom)
Result: Calls a machine code subroutine at memory location m. (Acorn Atom)
Not on the Spectrum. Use USR instead to call machine code.
LPRINT
LPRINT ... (ZX Spectrum)
Result: Send a line of characters to the ZX Printer or printer compatible with the LPRINT statement.
On the Spectrum LPRINT generally works with the ZX Printer but can sometimes be used with other printer interfaces.
The Acorn Atom does not have a statement like LPRINT to output to a printer, instead control codes are used to enable and disable the printer.
To enable the printer use CTRL-B, and to disable output to the printer use CTRL-C.
See also: COPY, LLIST.
MOVE
MOVE x,y (Acorn Atom)
Result: Repositions graphics cursor to location x,y.
Not on the Spectrum.
On the Spectrum the graphics cursor can be moved using:
POKE 23677,x
POKE 23678,y
where x and y are the coordinates to move the graphics cursor.
See also CIRCLE, DRAW, PLOT.
OPEN #
OPEN #m;f1[;n]¦[;n;f2] (ZX Spectrum)
Result: Open a stream m attached to channel f1 with device number n. Microdrives require a filename f2 (ZX Spectrum)
On the Spectrum the hash symbol after OPEN is not a single character but part of the OPEN # keyword.
Not on the Acorn Atom. No similar command appears to exist for the Atom.
OUT
OUT m,n (ZX Spectrum)
Result: Outputs byte n to port m.
Note: Executes the Z80A instruction OUT (c),a.
The Atom utilises the 8255 Programmable Peripheral Interface Adapter for input and output. Port A is location #B000, Port B is location #B001, and Port C is location #B002.
See also: IN.
OVER
OVER n
Result: If n=0 then permanent overprinting is turned off. If n=1 permanent overprinting is tunred on.
keyword OVER n
Result: If n=0 then temporary overprinting is turned off. If n=1 temporary overprinting is tunred on.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. No effect when applied to LPRINT.
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).
OVERprinting is not possible on the Acorn Atom.
See also: CHR$.
PAPER
PAPER n (ZX Spectrum)
Result (ZX Spectrum): Sets permanent background colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword PAPER n; (ZX Spectrum)
Result: Sets temporary background colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When PAPER is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The way the Acorn Atom handles colours is quite different to the ZX Spectrum. The only statement the Atom has to change the colours on the screen is the COLOUR statement.
COLOUR changes the 'background' colour which on the Spectrum would be the INK (not PAPER as would be expected). There is no PAPER equivalent on the Atom.
See also: COLOUR, INK.
PAUSE
PAUSE m (ZX Spectrum)
Result (ZX Spectrum): Stop program execution for m*1/50seconds or until a key is pressed.
On the Spectrum PAUSE is interupted when a key is pressed. Also, PAUSE 0 is not timed but lasts until a key is pressed.
The Acorn Atom's WAIT statement is quite different to PAUSE and the use of loops would work better if converting a program from the Atom to the Spectrum.
See also: WAIT.
PLOT
(Acorn Atom)
PLOTk,x,y
Result: Plots to the point at x,y. Result depends on value of k. (Acorn Atom)
First parameter k is as follows:
0 - plot line relative to last point with no change in pixels
1 - plot line relative to last point and set pixels
2 - plot line relative to last point and invert pixels
3 - plot line relative to last point and clear pixels
4 - plot line to absolute position with no change in pixels
5 - plot line to absolute position and set pixels
6 - plot line to absolute position and invert pixels
7 - plot line to absolute position and clear pixels
8 - plot point relative to last point with no change in pixel
9 - plot point relative to last point and set pixel
10 - plot point relative to last point and invert pixel
11 - plot point relative to last point and clear pixel
12 - plot point at absolute position with no change in pixel
13 - plot point at absolute position and set pixel
14 - plot point at absolute position and invert pixel
15 - plot point at absolute position and clear pixel
Similar to PLOT and DRAW on the Spectrum.
See also DRAW, PLOT (ZX Spectrum).
PLOT
(ZX Spectrum)
PLOT [c;]m,n (ZX Spectrum)
Result: Sets pixel ink at position m,n subject to c (INK/PAPER/OVER/INVERSE) on the ZX Spectrum.
On the Atom PLOT 13,x,y does the same as PLOT on the Spectrum.
PLOT INVERSE 1 on the Spectrum is PLOT 14,x,y on the Atom.
See also: CIRCLE, DRAW, PLOT (Acorn Atom).
POKE
(ZX Spectrum)
? (Question Mark)
(Acorn Atom)
POKE m,n (ZX Spectrum)
?m=n (Acorn Atom) 1st example
m1?m2=n (Acorn Atom) 2nd example
Result: Load byte n into memory address m.
2nd example on the Acorn Atom only: Load byte n into memory address m1+m2.
The question mark (?) used on the Acorn Atom is actually called a Byte Indirection Operator but it does work just like POKE.
Result: Send a series of items to the display subject to control characters (and AT/TAB/INK/PAPER/INVERSE/FLASH/OVER on the ZX Spectrum).
Similar on both micros but with many exceptions.
Note for Atom with floating-point ROM: Exactly as PRINT except no '$' expressions are allowed. All expressions are treated as floating-point expressions.
RANDOMIZE
(ZX Spectrum)
RANDOMIZE [n] (ZX Spectrum)
Result: Sets system variable SEED to n which will be the basis for pseudo-random numbers (RND). n can be any number between 0 and 65535. When n=0 or if no number is given, then the pseudo-random number sequence is based upon the time elapsed since the Spectrum was powered on.
The Acorn Atom has no RANDOMIZE statement, however memory locations 8 to 12 contain the seed, and can be set using '!' to the chosen startinq point.
ZX Spectrum keyboard shows shortened RAND and not RANDOMIZE.
See also: RND.
READ
READ e1,e2,e3, ... (ZX Spectrum)
Result: Read numeric or string information from DATA statement and pass to a variable or variables e1,e2,e3, ...
Not on the Acorn Atom but routines to simulate DATA, READ, and RESTORE can be found on this link and searching for chapter 8.7 "Reading Text".
See also DATA, RESTORE.
REM
REM ... (Acorn Atom and ZX Spectrum)
Result: None, displays comment in program listing.
Same result all round.
The Acorn Atom may also display remarks without a REM statement, but the line number without REM must either be skipped with a GOTO statement, or the program flow must not be directed to that line at all.
RESTORE
RESTORE [n] (ZX Spectrum)
Result: Restores DATA pointer to start of program or line number n, if specified.
Not on the Acorn Atom but routines to simulate DATA, READ, and RESTORE can be found on this link and searching for chapter 8.7 "Reading Text".
See also DATA, READ.
RETURN
RETURN
Result: Take line number off GO SUB stack and GO TO the line after that line number.
Same result all round.
See also GOSUB / GOSUB.
STOP
STOP
Result: Stops program execution. (ZX Spectrum).
CONTINUE will resume program execution.
Not on the Acorn Atom, use END instead.
See also END.
TAB
TAB x (ZX Spectrum)
Result (ZX Spectrum): Changes PRINT, LPRINT or INPUT position to column x.
The Atom does not have a TAB statement to tabulate text, however, a comma can be used to tabulate numbers but not characters or strings.
See also: PRINT, Comma (PRINT item).
WAIT
WAIT n (Acorn Atom)
Result: waits for 1/60th second for pulse from the CRT controller.
Not on the Spectrum. PAUSE 1 will give a pause of 1/50th second, this can, however, be interupted by a keypress.
See also: PAUSE.
Compound Statements
Keyword
Meaning
Comments
FOR...NEXT loop
(FOR, TO, STEP, NEXT)
FOR α=x TO y STEP z
[section of program to be repeated goes here]
NEXT α (ZX Spectrum)
NEXT [α] (Acorn Atom)
Result: Sets up and executes the loop α from x to y with a step of z.
[Note] Step of +1 assumed if STEP omitted).
Same result all round with the only exception being that the Acorn Atom does not require a control variable after a NEXT statement, although one may be used.
Although the NEXT statement is not compounded within the FOR statement as TO and STEP are, it is included here for completeness.
IF..THEN
(Acorn Atom and ZX Spectrum)
FIF..THEN
(Acorn Atom FP-ROM)
IF x [THEN] s (Acorn Atom)
FIF x [THEN] s (Acorn Atom FP-ROM)
IF x THEN s (ZX Spectrum)
Result: If x is true (non-zero) then s will be executed.
THEN is optional on the Acorn Atom with the exception that the statement following THEN does not begin with a T or a unary operator '!' or '?'.
Note for the Atom Floating-Point ROM: Same as IF, but connectives such as AND and OR are not allowed.
DO...UNTIL
(Acorn Atom)
DO..FUNTIL
(Acorn Atom FP-ROM)
DO
statements
UNTILcondition (Acorn Atom)
FUNTILcondition (Acorn Atom FP-ROM)
Result: Sets up and executes a DO loop and performs statements. When condition is met UNTIL closes the loop.
Not on the ZX Spectrum but a DO loop to wait for a keypress can be achieved with the following code.
LET exit=1
FOR d=0 TO 0 STEP 0
IF INKEY$<>"" THEN LET d=exit
NEXT d
Explanation:
The exit variable is set to '1'. This is just a convenient name to make the program easier to follow.
The FOR loop is a dummy loop which will be our DO.
Next comes the line which checks for a keypress. If true r, the DO loop variable, will be set to exit or 1, and the loop will be exited at NEXT d
NEXT d completes the loop, this is the equivalent of UNTIL.
FUNTIL is the same as UNTIL except that OR or AND are not allowed.
Functions
Keyword
Meaning
Comments
ABS
(Acorn Atom, Acorn Atom FP-ROM and ZX Spectrum)
A.
(Acorn Atom & Acorn Atom FP-ROM abbreviation)
ABS x (ZX Spectrum)
ABSx (Acorn Atom & Acorn Atom FP-ROM)
A. x (Acorn Atom & Acorn Atom FP-ROM abbreviation)
Returns: Absolute magnitude of x, i.e. distance on number line from zero, -1=1 -2=2
Same result all round.
ACS
(Acorn Atom FP-ROM and ZX Spectrum)
ACS x (Acorn Atom FP-ROM & ZX Spectrum)
Returns: Arccosine (inverse cosine) of x in radians.
Same on both micros.
ASN
(Acorn Atom FP-ROM and ZX Spectrum)
ASN x (Acorn Atom FP-ROM & ZX Spectrum)
Returns: Arcsine (inverse sine) of x in radians.
Same on both micros.
ATN
(Acorn Atom FP-ROM and ZX Spectrum)
ATN x (Acorn Atom FP-ROM & ZX Spectrum)
Returns: Arctangent (inverse tangent) of x in radians.
Same on both micros.
ATTR
ATTR (x,y)
Returns: numeric value between 0 and 255 of the attribute at position x,y.
Not on the Atom. See also POINT, SCREEN$.
CHR$ (ZX Spectrum)
$ (dollar sign) (Acorn Atom)
CHR$ x (ZX Spectrum)
$x (Acorn Atom)
Returns: Single character or control code, from position x in the character set.
Although the CHR$ / $ function performs the same task on both the Spectrum and Atom, the end result may be different. Both micros use a character set based on ASCII.
CODE (ZX Spectrum)
CH (Acorn Atom)
CODE α$ (ZX Spectrum)
CH$α (Acorn Atom)
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 / CH functions perform the same task on both computers, just like CHR$ above, the end result may be different.
Also, note the Atom uses $ as a prefix to the string indentifier, unlike the ZX Spectrum which uses $ as a suffix to the identifier.
See also: CHR$
COS
COS x (Acorn Atom FP ROM & ZX Spectrum)
Returns: Cosine of x in radians.
Same result all round.
COUNT
COUNT (Acorn Atom)
Returns: The number of characters printed since the last new line. COUNT is set to zero if the output stream is changed.
Since COUNT is a measure of how many characters have been displayed since the last new-line then the following code will perform a similar task on the ZX Spectrum:
LET count=33-PEEK 23688
See also: ' (apostophe).
DEG
DEG x (Acorn Atom FP-ROM)
Result: Converts x radians to degrees.
Not on the Spectrum.
The following definable function will do the same:
DEF FN d(x)=x*57.2957795
See also: RAD.
EXP
EXP x (Acorn Atom FP ROM & ZX Spectrum)
Returns: Numeric value for the function ex where:
e=2.7182818... (ZX Spectrum)
e=2.71828183 (Acorn Atom FP ROM)
Same result all round.
FLT
FLT(m) (Acorn Atom FP ROM)
Returns: Convert an integer m to a floating-point number. (Acorn Atom FP ROM)
Not required on the Spectrum.
See also INT.
FN
FN α(α1, αk) (ZX Spectrum)
Result: Calls a function. α and α1 to αk can be a single letter only or a single letter followed by $ for a string argument.
A definable function on the ZX Spectrum may be numeric or string.
Definable functions are not present on the Acorn Atom computer.
See also DEF FN.
HTN
HTN x (Acorn Atom FP ROM)
Returns: Hyperbolic tangent of angle of x radians. (Acorn Atom FP ROM)
Not on the Spectrum.
The following definable function will do the same:
DEF FN h(x)=2/(1+EXP (-2*x))-1
See also TAN.
INKEY$
(ZX Spectrum)
INKEY$
INKEY$ requires 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
The Acorn Atom does not have an INKEY$ statement, or similar. The Atom keyboard can be read by accessing I/O ports #B001 and #B002, which denote the ports for the keyboard matrix rows and columns.
IN
(ZX Spectrum)
? (Query/Question Mark)
(Acorn Atom)
IN m (ZX Spectrum)
?m (Acorn Atom)
Returns: numeric value between 0 and 255 for the port m.
IN and ? both perform a similar task, however the Acorn Atom utilises the 6502 microprocessor so results will be different.
See also: OUT, ? (Indirection Operator)
INT
(ZX Spectrum)
% (Percent sign)
(Acorn Atom FP-ROM)
INT x (ZX Spectrum)
%x (Acorn Atom FP-ROM)
Returns (ZX Spectrum): The greatest integer (floor) of x.
Returns (Acorn Atom FP-ROM): The least integer (ceiling) of x.
The ZX Spectrum INT function returns the floor integer or greatest integer whereas the Acorn Atom returns the ceiling integer or least integer.
To return the ceiling integer on the Spectrum use this code:
LET c=SGN x*INT ABS x
where x is a real number and c is the ceiling integer.
On the ZX Spectrum when INT -65536 is performed (the wrong result is given as -1).
LEN
LEN α (Acorn Atom)
LEN α$ (ZX Spectrum)
Returns: numeric value for the length of $α (Acorn Atom) / α$ (ZX Spectrum).
Same result all round.
The Atom does not use dollar-prefix ($) for the string indentifier when using LEN, so a string variable which has been defined by a DIM statement, and is referred to in a program as $α, will just be referred to as α in a LEN statement.
LN (ZX Spectrum)
LOG (Acorn Atom FP-ROM)
LOG x (Acorn Atom FP-ROM)
LN x (ZX Spectrum)
Returns: numeric value for the natural logarithm of x.
Similar result all round.
See also EXP, ↑.
LOG
See LN
PEEK
(ZX Spectrum)
? (Query/Question Mark)
(Acorn Atom)
?m (Acorn Atom)
PEEK m (ZX Spectrum)
Returns: numeric value (0 to 255) stored at memory location m.
PEEK / ? (Question Mark) on the Spectrum and the Atom have the same purpose although both will yield different results depending on the context of the program within which it is used.
See also POKE, indirection operators.
POINT
POINT (x,y) (ZX Spectrum)
Returns: 1 if pixel is on or 0 if it is off, for the pixel location x,y.
There is not an equivalent function on the Atom, however the state of a pixel can be retrieved from video memory.
RAD
RAD x (Acorn Atom FP-ROM)
Result: Converts x degress to radians.
Not on the Spectrum.
The following definable function will do the same:
DEF FN r(x)=x*0.01745329
See also: DEG.
RND
RND (Acorn Atom and ZX Spectrum)
Result: A pseudo-random number between 0 and 1 (ZX Spectrum).
Result: A random whole number between -2147483648 and 2147483647 (Acorn Atom).
The Atom's
RND
can be simulated on the ZX Spectrum with:
INT -(RND*2147483648)+2147483647
See also RANDOMIZE.
SCREEN$
SCREEN$ (x,y) (ZX Spectrum)
Returns: character displayed at location x,y.
Not on the Atom.
See also POINT.
SGN
SGN x (Acorn Atom FP and ZX Spectrum)
Returns: signum (or sign) of x, for instance -1 if x<0, 0 if x=0 or 1 if x>1.
Same on the ZX Spectrum and the Acorn Atom with Floating-Point ROM.
SIN
SIN x (Acorn Atom FP and ZX Spectrum)
Returns: Sine of x in radians.
Same on the ZX Spectrum and the Acorn Atom with Floating-Point ROM.
SQR
SQR x (Acorn Atom FP ROM & ZX Spectrum)
Returns: square root of x.
Same on the ZX Spectrum and the Acorn Atom with Floating-Point ROM.
STR$
(ZX Spectrum)
STR
(Acorn Atom FP-ROM)
STR$ x (ZX Spectrum)
Result: string comprising of the numeric value of x.
STR x addr (Acorn Atom FP-ROM)
Result: string comprising of the numeric value of x is stored at address addr.
The Acorn Atom has to pass the value of x to an address in memory before it can be passed to, say, a PRINT statement, whereas the ZX Spectrum does this automatically without intervention from the user.
See also: VAL
TAN
TAN x (Acorn Atom FP and ZX Spectrum)
Returns: Tangent of x in radians.
Same on the ZX Spectrum and the Acorn Atom with Floating-Point ROM.
USR
(Numeric argument)
USR m (ZX Spectrum)
Returns: contents of the bc register pair after calling machine code at memory location m.
The ZX Spectrum will return the value of the bc register pair (Z80).
The Acorn Atom does not have a USR function but instead uses the LINK command to run a machine code subroutine.
See also LINK.
USR
(String argument)
USR α$ (ZX Spectrum)
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.
The Acorn Atom does not have a simple way of creating user defined graphics, it is possible to create them but this is complex and beyond the scope of this article.
VAL
VAL($α) (Acorn Atom FP-ROM)
VAL α$ (ZX Spectrum)
Returns: numeric value evaluated from the string α$.
The Acorn Atom will only evaluate numbers, anything else will return a zero and only the first value before an expression will be evaluated i.e.VAL("10*20") will evaluate as 10.
The ZX Spectrum will evaluate numbers, mathematical operators, logical operators and variables.
VAL$
VAL$ α$
Returns: string evaluated from the string α$.
There does not appear to be a simple way to simulate this function in Atom Basic*
For an explantion of the VAL$ function follow this link.
*The way the Acorn Atom handles strings is a bit quirky but does mean that the memory locations that a string occupies are highly accessible to BASIC and therefore it is possible a subroutine could be created to simulate the ZX Spectrum's VAL$ function, although to do so may be impractical.
Constants
Keyword
Meaning
Comments
PI
PI
PI requires no operands.
Returns: 3.1415927 (ZX Spectrum) or 3.14159265 (Acorn Atom FP-ROM)
(π) Ratio of circumference of a circle to its diameter
Typical usage might be:
LET R=C/(2*PI)
PI (π) is stored on the Spectrum as 10 digits but will only display 8 digits.
Pseudo-Variables
Keyword
Meaning
Comments
@ (at sign)
@=m (Acorn Atom)
Result: Alters the numbers of spaces (m) between printable characters after a comma.
Like the ZX Spectrum TAB but unlike TAB the value is not fixed.
TOP
TOP (Acorn Atom)
Returns: the address of the first free byte after the end of a stored BASIC program.
Similar to the ZX Spectrum system variable 'RAMTOP' which is stored in two bytes at locations 23730 and 23731.
Operators
Keyword
Meaning
Comments
-
Unary Minus/Negation
-x
Result: negates x.
Same result all round.
-
Binary Minus/Subtraction
x-y
Result: a numeric value resulting from y being subtracted from x.
Same result all round.
+
Addition
x+y
Result: a numeric value resulting from y being added to x.
Same result all round.
+
String concatenation
α$+β$ (ZX Spectrum)
$α+LEN(α)=$β (Acorn Atom)
Result: concatenates (joins together) string α with string β to form a new string.
Same result all round.
Note the unusual way the Atom handles strings e.g. $&alpha refers to string variable α, but so does α without the $ (dollar sign).
/
Division
x/y
Result: a numeric value resulting from x being divided by y.
An unxpanded Acorn Atom will give an integer result for x/y.
*
Multiplication
x*y
Result: a numeric value resulting from x being multiplied by y.
Same result all round.
↑
Raise to the power of
x↑y (ZX Spectrum and Acorn Atom FP-ROM)
Result: a numeric value resulting from x being raised to the power of y (xy).
On the ZX Spectrum, if the base number (x) is negative it will produce an 'Invalid Argument' error. A function can be defined to get round this :
DEF FN e(x,y)=(SGN x*(y/2<> INT (y/2)+(y/2=INT (y/2)))*ABS x↑y
An error will also occur on the Atom if the base number is negative displaying ERROR 191.
<
Less than
x<y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Acorn Atom).
Result: 1 if x<y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the < operator.
The Acorn may require brackets around the expression in some contexts.
>
Greater than
x>y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Acorn Atom).
Result: 1 if x>y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the > operator.
The Acorn may require brackets around the expression in some contexts.
<=
Less than or equal to
x<=y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Acorn Atom).
Result: 1 if x≤y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the <= operator.
The Acorn may require brackets around the expression in some contexts.
>=
Greater than or equal to
x>=y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Acorn Atom).
Result: 1 if x≥y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the >= operator.
The Acorn may require brackets around the expression in some contexts.
=
Variable assignment
[LET] x=y (Acorn Atom)
LET x=y (ZX Spectrum)
Where x and y can be either numeric or strings but cannot be mixed.
Result: x is assigned the value y.
Also used with DIM and DEF FN.
The LET keyword is optional on the Atom.
=
Is equal to
x=y
Where x and y can be either numeric or strings but cannot be mixed.
Result (ZX Spectrum): 1 if x=y otherwise 0.
Result (Acorn Atom): condition true if x=y otherwise condition false.
Similar result on both micros.
The Acorn may require brackets around the expression in some contexts.
<>
Is not equal to
x<>y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x≠y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the <> operator.
The Acorn may require brackets around the expression in some contexts.
AND
(Acorn Atom and ZX Spectrum)
A.
(Acorn Atom abbreviation)
x AND y (Acorn Atom and ZX Spectrum)
x A. y (Acorn Atom abbreviation)
Where x is a number or a string, and y is always numeric. (ZX Spectrum)
Where x and y are both expressions. (Acorn Atom)
Returns (ZX Spectrum): x if y is true (non-zero) or 0 if y is false (zero).
Returns (Acorn Atom): 1 if x and y are true, 0 if x or y are false.
The Atom only uses expressions with AND.
The Acorn may require brackets around the expression in some contexts.
BIN
BIN b (ZX Spectrum)
Returns: decimal value of a base2 (binary) 16 bit number.
Not strictly a function but a numerical notation. Not on the Acorn Atom, although a short subroutine could be written to emulate the Spectrum BIN statement.
#
Hash
as a hexadecimal number prefix
#h (Acorn Atom)
Returns: a decimal (base10) number from the hexadecimal (base16) number h.
A short BASIC routine could be written to convert hexadecimal to decimal, on the Spectrum.
&
(Acorn Atom)
Bitwise AND
m&n
Where m and n are both numeric. (Acorn Atom)
Result : An integer from the bitwise calculation of m and n. Bits in m and n are compared. If the bits in both m and n are 1 then the resulting bit, after performing a bitwise AND, will be 1 otherwise it will be 0. (Acorn Atom)
A short machine code routine could simulate bitwise AND on the ZX Spectrum.
%
(Acorn Atom)
Remainder
m%n (Acorn Atom)
Returns: Remainder of m divided by n.
The remainder can be found on the Spectrum with the function:
DEF FN R(m,n)=INT(m-(INT(m/n)*n))
See also: INT.
NOT
NOT x¦e
Where x is numeric, or an expression may be used.
Returns (ZX Spectrum): zero if x≠0, 1 if x=0.
The Acorn Atom does not have a NOT operator.
OR
x OR y
Where x and y are both numeric.
Returns (Acorn Atom and ZX Spectrum): 1 if x or y≠0, value of x if y=0.
A similar result may occur on both the Spectrum and the Acorn Atom.
The Acorn Atom may sometimes require brackets around an expression.
Indirection Operators
Keyword
Meaning
Comments
? (Query or Question Mark)
(Acorn Atom)
?m=n (Acorn Atom)
Result: Load byte n into memory address m (like POKE).
v=?m (Acorn Atom)
Result: Read byte from memory address m and place in variable v (like PEEK).
PRINT ?m (Acorn Atom)
Result: Read byte from memory address m and display (like PEEK).
This is just like PEEK and POKE on the ZX Spectrum.
See also: PEEK, POKE.
! (pling or Exclamation Mark)
(Acorn Atom FP-ROM)
!m=n (Acorn Atom FP-ROM)
Result: Load word n to memory starting at address m.
v=!m (Acorn Atom FP-ROM)
Result: Read word from memory m0 to m3 and place in variable v.
FPRINT %!m (Acorn Atom FP-ROM)
Result: Read word from memory address m0 to m3 and display.
The word m is read from memory little-endian style.
On the Spectrum we can load a 4 byte word to memory with:
$v+y1=""; $v=$v+x (Acorn Atom equivalent - where y1 is equal to y+1
v$(x TO) (ZX Spectrum)
$v=$v+x1 (Acorn Atom equivalent - where x1 is equal to x+1)
v$(TO y) (ZX Spectrum)
$v+y="" (Acorn Atom equivalent)
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).
Although the Acorn Atom does not have the TO keyword string slicing is possible.
Equivalent Acorn Atom string slicing is shown in the column to the left below each ZX Spectrum example.
, (Comma) or ; (Semi-colon) as PRINT item seperators
; (Semi-colon)
(ZX Spectrum)
, (Comma)
(Acorn Atom - where @=1)
PRINT ; (ZX Spectrum)
PRINT , (Acorn Atom - where @=1)
INPUT ; (ZX Spectrum)
INPUTmessage;v (ZX Spectrum)
Result: separates items within a PRINT, LPRINT, or INPUT statement.
message is text within double quotes. v is a numeric or string variable.
The Acorn Atom comma can work like the Spectrum's semi-colon when @=1.
See also: @ (at sign) , ',' (comma).
'
Apostrophe / Single Quote
PRINT ' (ZX Spectrum and Acorn Atom)
LPRINT ' (ZX Spectrum only)
INPUT ' (ZX Spectrum and Acorn Atom)
Result: Moves the PRINT or LPRINT position down a line.
Similar results on both micros.
See also: COUNT.
,
Comma
as a PRINT item
PRINT , (Acorn Atom and ZX Spectrum)
LPRINT , (ZX Spectrum only)
INPUT , (Acorn Atom and ZX Spectrum*)
Result (ZX Spectrum) : Moves the PRINT position to halfway across the screen (or printer) or to the start of the next line if PRINT position is greater or equal to halfway.
Result : Moves the PRINT position according to the value of the pseudo-variable '@'.
ZX Spectrum INPUT comma works, just like the PRINT comma, by moving the PRINT position 15 characters along.
If @=1 then a comma acts like the Spectrum's semi-colon.
If @=15 then the comma will move the PRINT position 15 characters, like the Spectrum.
See also: '@' (at sign) , ';' (semi-colon).
,
Comma
as an operand/parameter delimiter
Examples:
POKE x,y (ZX Spectrum)
MOVE x,y (Acorn Atom)
Result: Separates operands/parameters within a statement.
Mostly the same all round.
#
Hash
as a stream prefix
PRINT #m (ZX Spectrum only)
LPRINT #m (ZX Spectrum only)
OPEN #stream_number;device;device_number;filename
(ZX Spectrum with ZX Interface 1)
Result: Channel input/ouput through stream m.
The standard Acorn Atom does not have I/O streams and channels.
Some statements on the ZX Spectrum may require the ZX Interface 1.
: (Colon) or ; (Semi-colon) as statement delimiters
: (Colon)
(ZX Spectrum)
; (Semi-colon)
(Acorn Atom)
s1 : s2 : s3 : ... (ZX Spectrum)
s1 ; s2 ; s3 ; ... (Acorn Atom)
Result: Allows more than one statement per line number to be entered.
Same result except for the different punctuation used.
"
Double quotation marks
$α="some text" (Acorn Atom)
α$="some text" (ZX Spectrum)
PRINT "some text" (Acorn Atom and ZX Spectrum)
LPRINT "some text" (ZX Spectrum)
INPUT "some text" (ZX Spectrum)
Result: Encloses text within a string or within a PRINT, INPUT or LPRINT statement.
ZX Spectrum and the Acorn Atom can both store a double quote within a pair of quotation marks like so
""some text""
produces the output:
"some text"
Nomenclature
This list uses the same letters to represent variables, expressions and sequences etc. as the ZX Spectrum BASIC manual.
α,β 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
h represents a hexadecimal 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 colour item has the form of a PAPER, INK, FLASH, BRIGHT, INVERSE or OVER statement.
References
Sinclair ZX Spectrum BASIC Programming, Steven Vickers (author), Robin Bradbeer (editor)
Atomic Theory and Practice - A beginner's course in BASIC and machine code programming, David Johnson-Davies (author), ACORN COMPUTER LTD (publisher)