×

Search this site

For your Information. When using the search box on this page you will be directed to an external search engine (freefind.com) which may contain adverts not affiliated to MisterSpectrum.com. If you do not wish to continue please click on the 'X' in the right hand corner of this pop-up.



A Comparision of Keywords on the BBC Micro (Models A & B), the Acorn Electron and the ZX Spectrum


BBC BASIC



Overview

The following is a list of keywords, operators and delimiters used on the BBC Micro (Models A & B), the Acorn Electron and the ZX Spectrum.

The BBC Micro was released in 1981 by Acorn Computers Ltd as a result of the British Broadcasting Corporation's Computer Literacy Project. It has a very structured version of BASIC called BBC BASIC which includes named procedures, REPEAT...UNTIL structure, multi-line functions and long name variables.

The Acorn Electron, also released by Acorn Computers, was released in 1983 to compete with the ZX Spectrum.

The Electron is mostly compatible with the BBC Micro with just a few differences, one of which is the lack of Teletext Mode (MODE 7).

This list focuses on BBC BASIC II keywords as used on the Acorn Electron and BBC Micro (Models A & B) and their similarities and differences to Sinclair BASIC. It does not cover the later models such as the B+64, B+128, Master 128, and Master Compact nor does it cover the Acorn Atom and Acorn Archimedes range.

Some commands have been left off this list as they are either not relevent or they do not have a ZX Spectrum equivalent.

The *FX and VDU sections will be expanded in the future.



Commands

Keyword

Meaning

Comments

*FX


*FX m,n (BBC Micro & Acorn Electron only)

Result: Allows the user to control a number of computer effects.  (BBC Micro & Acorn Electron)

Not on the Spectrum, similar to setting the system variables.

CHAIN


CHAIN f (BBC Micro & Acorn Electron only)

Result: LOAD & RUN program f. If f is and empty string then the first program on tape encountered will be loaded. (BBC Micro & Acorn Electron)

Not on the Spectrum but there are several ways to simulate CHAIN. One way is to LOAD several programs which have been previously saved to autorun from a specific line number one after another. Each program loaded will overwrite the last.

Another way would be to LOAD a bootstrap program which in turn would MERGE subsequent programs which could then be RUN. Any duplicate line numbers will be overwritten so care must be taken when using this method.

See also MERGE, MERGE, SAVE, VERIFY.

CLEAR n

ZX Spectrum (command)


CLEAR n  (ZX Spectrum)

Result: Clears the screen, deletes all variables, resets PLOT and PRINT positions and clears the GOSUB stack then RAMTOP is lowered to n. (ZX Spectrum)

ZX Spectrum
A CLEAR command on the BBC Micro and Acorn Electron which sets aside space in memory does not exist. Instead these computers use the HIMEM pseudo-variable to change memory allocated to BASIC programs.

See also CLEAR (statement), HIMEM.

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. (ZX Spectrum)

ZX Spectrum
CONTINUE is shortened to CONT on the ZX Spectrum keyboard.

There is no equivalent to CONTINUE on the BBC Micro or Acorn Electron micros.

LIST


LIST  (ZX Spectrum, BBC Micro & Acorn Electron)

Result: Display complete program listing.

LIST n  (ZX Spectrum)

Result: Display program listing from line n or line 0 where no line number specified (ZX Spectrum).

LIST n  (BBC Micro & Acorn Electron)

Result: Display single program line n.

LIST [m],[n]  (BBC Micro & Acorn Electron)

Result: Display program listing from line m to line n. If m is omitted listing will begin at the start of the program. If n is omitted then listing will stop at the end of the program. If both m and n are omitted, i.e.LIST , ,the complete program will be listed (same as LIST).
ZX Spectrum
Note: The BBC Micro & Acorn Electron cannot use LIST as part of a program, it can only be used as a direct command.

See also LLIST.

LLIST


LLIST  (ZX Spectrum)

Result: Send a complete program listing to the printer.

LLIST n  (ZX Spectrum)

Result: Print the program listing from line n or line 0 where no line number specified.

ZX Spectrum
The BBC & Electron do not have an LLIST command but instead use LIST with the printer being turned on and off with CTRL B and CTRL C respectively.

See also LIST.

LOAD


LOAD f  (ZX Spectrum)

Result: Load program f.



LOAD α$  (BBC Micro & Acorn Electron)

Result: Loads a program α$ into the computer from cassette tape, disc or Econet, which ever is the current filing system.



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 only)

Result: Load data from cassette into the memory location specified when the file was saved. If m is specified then load into memory location m. Optionally n (number of bytes to load) may also be specified)



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 )

ZX Spectrum
ZX Spectrum has extra options to load dimensional arrays, code direct to memory or a screen to the display file.

See also CHAIN, MERGE, SAVE, VERIFY.

MERGE


MERGE f

Result: Merge program f with that already in memory overwriting duplicate program lines.
ZX Spectrum
Not on the BBC Micro or Acorn Electron.

NEW


NEW

Result: Deletes program and variables and memory up to and including the address held in the system variable RAMTOP (ZX Spectrum).

Result: Resets internal pointers to ‘delete’ all program statements which may be recovered with OLD provided no new statements have been entered and no new variables have been created (BBC Micro & Acorn Electron).

ZX Spectrum
Similar on both micros. On the Acorn machines NEW preserves the resident integer variables A% to Z% or @% and does not clear the screen. On the ZX Spectrum NEW preserves the system variables UDG, P-RAMT, RASP and PIP.

See also OLD.

OLD


OLD

Result: Restores BASIC program previously deleted by NEW or by press BREAK. (BBC Micro & Acorn Electron).

On the Spectrum there is no way to restore a program once NEW has been executed.

See also NEW.

RUN


RUN  (BBC Micro & Acorn Electron)

Result: All variables (except the resident integer numeric variables @% and A% to Z%) are first deleted and then the program is executed.


RUN [n]

Result: Perform CLEAR and GO TO line n (or line 0 if n not specified)

ZX Spectrum
Similar on both micros. On the Acorn machines RUN preserves the resident integer variables A% to Z% or @% and does not clear the screen. On the ZX Spectrum RUN clears all variables and the screen.

See also GOTO/GO TO.

SAVE


SAVE f  (ZX Spectrum, BBC Micro & Acorn Electron)

Result: Save program f to tape.



SAVE f LINE m  (ZX Spectrum)

Result: Save program f to tape. RUN program from line m when reloaded.



SAVE f DATA α[$]()  (ZX Spectrum)

Result: Save array α to tape.



SAVE f CODE m,n  (ZX Spectrum)

Result: Save code from memory to tape starting at address m with a length of n bytes.



SAVE f SCREEN$  (ZX Spectrum)

Result: Save display file with filename f to tape (same as SAVE f CODE 16384,6192).

ZX Spectrum
BBC/Electron filenames can be up to 10 characters long (or 7 for the Disc Filing System) and must start with a letter, contain no space or punctuation. ZX Spectrum filenames can be up to 10 characters long and may contain any ASCII characters including control codes. ZX Spectrum has extra options to save dimensional arrays, code from memory or the display file.

See also CHAIN, MERGE, LOAD, VERIFY.

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: Compares program/array/code f from tape with that in memory. Error R if verify fails.

ZX Spectrum
Not available on the BBC or Electron.

See also CHAIN, MERGE, LOAD, SAVE.


Statements

Keyword

Meaning

Comments

AT


PRINT AT m,n;  (ZX Spectrum)

INPUT AT m,n;  (ZX Spectrum)

Result: Changes PRINT position to row m, column n. Also works with INPUT but result is less apparent unless BORDER colour differs from PAPER colour.

ZX Spectrum
On the ZX Spectrum AT must follow a PRINT or INPUT statement:

PRINT AT 10,10;"Arthur"

For the BBC & Electron TAB is used instead with the row and column parameters reversed.

See also INPUT, PRINT, TAB.

BEEP


BEEP x,y

Result: Sound emitted for x seconds at pitch y.
ZX Spectrum
For the Acorn equivalent sound statement see SOUND. See also ADVAL, ENVELOPE, SOUND.

BORDER


BORDER m

Result: Changes screen border colour to m.
ZX Spectrum
It is not possible to change the border on the Electron or BBC.

BRIGHT


BRIGHT n

Result: When n=1 permanent brightness is turned on. When n=0 permanent brightness is off.

keyword  BRIGHT 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.
ZX Spectrum
The brightness of the screen cannot be changed on the Acorn machines.

CIRCLE


CIRCLE x,y,z (ZX Spectrum)

Result: Draws a circle of radius z at position x,y.

ZX Spectrum
A subroutine must be created on the Acorn Electron and BBC Micro to draw a circle as it does not have a built in CIRCLE statement.

See also DRAW, PLOT, MOVE.

CALL


CALL m[,x|f] (BBC Micro & Acorn Electron)

Result: Calls a machine code subroutine at memory location m. Optional numeric parameter x or string parameter f may be passed to the routine. (BBC Micro & Acorn Electron)

Not on the Spectrum. Use USR instead to call machine code.

CLEAR


CLEAR

Result: Clears the screen, deletes all variables, resets PLOT and PRINT positions and clears the GOSUB stack.

Result: Deletes all variables except resident integer variable A% to Z% & @% (BBC Micro & Acorn Electron)
ZX Spectrum
CLEAR on the BBC Micro & Acorn Electron only deletes variables and does not clear the screen.

See also CLEAR (command), CLG.

CLG


CLG  (BBC Micro & Acorn Electron only)

Result: Clears the graphics screen, sets screen colour to the current selected colour and moves the graphics cursor to (0,0). The current PRINT position is unchanged. (BBC Micro & Acorn Electron)

Not on the Spectrum as the it only has one graphic mode.

When converting to the ZX Spectrum normally a CLS would suffice, however for a more precise translation CLG can be simulated with the following code.

LET x=33-PEEK 23688

LET y=24-PEEK 23689

CLS

PRINT AT x,y;

The LET statements store the current PRINT position.

CLS clears the screen.

PRINT AT restores the print position.

See also CLS, GCOL

CLS


CLS

Result: Clears the screen and sets cursor/print position to (0,0).

ZX Spectrum
On the ZX Spectrum CLS also sets the PLOT position to 0,0.

COLOUR


COLOUR n  (BBC Micro & Acorn Electron only)

Result: Sets the foreground/background text colour. (BBC Micro & Acorn Electron)


Note: Does not work in MODE 7 (BBC Micro)




Example:

To change the foreground text colour to cyan and the background text colour to magenta in MODE 2 use the following code:

COLOUR 6

COLOUR 133

For other modes and colours consult the table below.



In MODE 0, 3, 4 or 6 the following normally apply:

Foreground Colours

0 - Black
1 - White


Background Colour

128 - Black
129 - White




In MODE 1 or 5 the following normally apply:

Foreground

0 - Black
1 - Red
2 - Yellow
3 - White

Background Colour

128 - Black
129 - Red
130 - Yellow
131 - White




In MODE 2 the following normally apply:

Foreground

0 - Black
1 - Red
2 - Green
3 - Yellow
4 - Blue
5 - Magenta
6 - Cyan
7 - White
8 - Flashing black/white
9 - Flashing red/cyan
10 - Flashing green/magenta
11 - Flashing yellow/blue
12 - Flashing blue/yellow
13 - Flashing magenta/green
14 - Flashing cyan/red
15 - Flashing white/black

Background Colour

128 - Black
129 - Red
130 - Green
131 - Yellow
132 - Blue
133 - Magenta
134 - Cyan
135 - White
136 - Flashing black/white
137 - Flashing red/cyan
138 - Flashing green/magenta
139 - Flashing yellow/blue
140 - Flashing blue/yellow
141 - Flashing magenta/green
142 - Flashing cyan/red
143 - Flashing white/black


When using the codes for flashing colours the text will alternately switch between two colours for either or both foreground or background.

INK, PAPER and FLASH can be used to simulate COLOUR on the Spectrum.

For example to siumlate :

COLOUR 6

COLOUR 133

use this code on the Spectrum:

PAPER 5 : INK 3

In MODE 2 the BBC and Electron can alternately display 2 different foreground and background colours when using flashing codes, whereas the Spectrum can only flash between 1 foreground (the INK) and 1 background (the PAPER).

See also INK, PAPER, FLASH, MODE

COPY


COPY  (ZX Spectrum)

Result: Sends the contents of the screen to the ZX Printer.

ZX Spectrum
Not on the Acorn Electron or BBC Micro.

DATA


DATA e1,e2,e3, ...

Result: Stores data in a list.
ZX Spectrum
The ZX Spectrum requires string data to be surrounded by quotes, the BBC Micro & Acorn Electron do not unless leading spaces are required within a string.

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 or result. Brackets are obligatory even if there are no arguments i.e. DEF FN α()=e

DEF FNα[(α1[,...,αk])]=e  (BBC Micro & Acorn Electron)

Result: Defines a function. α and α1 to αk can be a single letter or two more more letters followed by $ for a string argument or result. If there are no arguments then brackets must not be used.

ZX Spectrum
On the BBC Micro and Electron there is no space between 'FN' and the function name.

BBC Micro & Acorn Electron computers can also define a function over multiple program lines. See DEF FN (Structured Statement).

See also FN.

DIM  (i)


DIM α(n1,...,nk)  

DIM α$(n1,...,nk)  

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) (ZX Spectrum) or null (BBC Micro & Acorn Electron).
ZX Spectrum
BBC & Electron arrays have a base of 0, unlike the ZX Spectrum which has a base of 1, so the code for an array of 10 numbers on the BBC and Electron would be

DIM A(9)

whereas on the ZX Spectrum it would be

DIM A(10)

DIM  (ii)

(BBC Micro & Acorn Electron)


DIM α n

Result: Reserve a number of bytes (n+1) in memory. α returns address of reserved bytes.  (BBC Micro & Acorn Electron).

This usage of DIM is not available on the Spectrum. Use CLEAR and POKE instead.

DRAW


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. Option colour statements (c) may be used.  (ZX Spectrum)

DRAW x,y  (BBC Micro & Acorn Electron)

Result: Draw a line from end of the last line or a new point if the MOVE statement has been used before DRAW.

ZX Spectrum
The ZX Spectrum uses relative coordinates whereas the BBC and Electron use absolute coordinate.

The following functions can be used on the Spectrum to make DRAW work with absolute coordinates.

DEF FN x(x)=x-PEEK 23677

DEF FN y(y)=y-PEEK 23678

DRAW FN x(x),FN y(y)

See also MOVE (BBC Micro & Acorn Electron), PLOT(BBC Micro & Acorn Electron), PLOT (ZX Spectrum).

END


END

Result: Terminates program and returns control to the user. (BBC Micro & Acorn Electron).
END differs from STOP in only that STOP displays the line number where the program was interupted, END does not.

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.

ENVELOPE


ENVELOPE N,T,PI1,PI2,PI3,PN1,PN2,PN3,AA,AD,AS,AR,ALA,ALD

Result: When used with the SOUND statement controls the volume and pitch of a sound while it is playing. (BBC Micro & Acorn Electron).

Envelopes has 14 parameters:

N - Envelope number (1 to 4)
T - (bits 0-6) Length of each step in hundredths of a second, (bit 7) toggles auto-repeat pitch envelope
PI1 - (-128 to 127) Change of pitch per step in section 1
PI2 - (-128 to 127) Change of pitch per step in section 2
PI3 - (-128 to 127) Change of pitch per step in section 3
PN1 - (0 to 255) Number of steps in section 1
PN2 - (0 to 255) Number of steps in section 2
PN3 - (0 to 255) Number of steps in section 3
AA - (-127 to 127) Change of amplitude per step during attack phase
AD - (-127 to 127) Change of amplitude per step during decay phase
AS - (-127 to 0) Change of amplitude per step during sustain phase
AR - (-127 to 0) Change of amplitude per step during release phase
ALA - (0 to 126) Target level at end of attack phase
ALD - (0 to 126) Target level at end of decay phase

Not on the Spectrum and not really possible to simulate with BEEP although PLAY on the 128K Spectrums does have a very simple envelope facility.

See also ADVAL, BEEP, SOUND.

FLASH


FLASH n  (ZX Spectrum only)

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.

keyword FLASH n  (ZX Spectrum only)

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.

ZX Spectrum
Flashing characters are possible on the Acorn Electron and BBC Micro in MODE 2 using the COLOUR statement and on the BBC Micro in MODE 7 using character code 136.

See also BRIGHT, COLOUR, INVERSE, MODE, VDU.

GCOL


GCOL m,n 

Result: Sets the colour to be used by all subsequent graphics operations. (BBC Micro & Acorn Electron).

The first number (m) specifies mode of action:

m=0 - Plot the colour specified
m=1 - OR the specified colour with that already there
m=2 - AND the specified colour with that already there
m=3 - Exclusive-OR the specified colour with that already there
m=4 Invert the colour already there

The second number (n) defines the logical colour to be used in future.

If the n>127 then n defines the graphics background colour.
If the n<128 then n defines the graphics foreground colour.

Not on the Spectrum. INK, PAPER and BRIGHT can be used instead to change the colour of PLOT, DRAW and CIRCLE

See also COLOUR, PLOT (BBC Micro & Acorn Electron), PLOT (ZX Spectrum), DRAW, CIRCLE.

GOSUB or GO SUB


GOSUB n¦(e)  (BBC Micro & Acorn Electron)

GO SUB n¦e  (ZX Spectrum)

Result: Stack GO SUB line number and branch (GO TO) line n or the line number derived from an expression (e).
ZX Spectrum
Same result all round with the exception of the spelling, GO SUB with a space for the Spectrum and without (GOSUB) for the BBC and Electron.
The ZX Spectrum manual is inconsistent with the spelling of GO SUB, using both GO SUB and GOSUB!

See also ON..GOSUB, RETURN.

GOTO or GO TO


GOTO n¦(e)  (BBC Micro & Acorn Electron)

GO TO n¦e  (ZX Spectrum)

Result: Branch or GO TO line n or the line number derived from an expression (e).
ZX Spectrum
Again, like above the same result all round with the exception of the spelling, GO TO with a space for the Spectrum and without (GOTO) for the BBC and Electron.

See also ON...GOTO

INK


INK n

Result: 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.

keyword INK n;

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.

ZX Spectrum
On the Acorn Electron and BBC Micro the COLOUR and GCOL statement are used to set foreground and background colour in modes 0 to 6.

In MODE 7 on the BBC Micro colours are set with control codes.

See also COLOUR, GCOL, PAPER, VDU.

INPUT


INPUT v1[,v2,v3...]  (ZX Spectrum, BBC Micro and Acorn Electron)

INPUT LINE α$   (ZX Spectrum, BBC Micro and Acorn Electron)

Result: Computer waits for input of an expression then passes the value of this to the variable v.
ZX Spectrum
The ZX Spectrum 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.

On BBC & Electron multiple data may be entered in one input line, for instance INPUT A,B may be input as 1,2 or INPUT A$,B$ may be input as "ABC","DEF" (note the double quotes).

INPUT LINE on the Acorn computers is different to INPUT LINE on the Spectrum. Using the previous example INPUT LINE A$ will allow quotes and commas to be entered as if part of the string.

INVERSE


INVERSE n

Result: Turns permanent inverse video effect on when n=1 or off when n=0.

keyword INVERSE 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.

On the Acorn Electron and BBC Micro inverting text and graphics in modes 0 to 6 is a bit more involved but can be achieved with the COLOUR and GCOL statements.

In MODE 7 on the BBC Micro the foreground and background text colour can be changed with control codes to give the same effect as inverting.

See also COLOUR, GCOL, INK, PAPER, VDU.

LET  (ZX Spectrum)

[LET]  (BBC Micro & Acorn Electron)


LET v=e  (ZX Spectrum)

[LET] v=e  (BBC Micro & Acorn Electron)

Result: Assign the value e to the variable v.
ZX Spectrum
LET is optional on the Acorn computers, i.e. :

α$="some text"

The BBC & Electron cannot use LET during the assignment of the pseudo-variables LOMEM, HIMEM, PAGE, PTR#, TIME.

See also DIM.

LOCAL


LOCAL v [v1, v2...,vk]

Result: Creates a temporary variable within a procedure or function. (BBC Micro & Acorn Electron)

Local variables are not available on the ZX Spectrum.

A type of local variable can be achieved on the Spectrum with the following:

REM A subroutine

LET local a=a

[code which uses a goes here]

LET a=local a

RETURN

The above works for numeric variables but not loop variables (FOR...NEXT)

For strings:

REM A subroutine

LET b$=a$

[code which uses a$ goes here]

LET a$=b$

RETURN

See also DEF FN (Structured Statement), DEF PROC...END PROC.

LPRINT


LPRINT ...

Result: Send a line of items to be printed to the ZX Printer.
ZX Spectrum
Only on the Spectrum.

For the Acorn Electron and BBC Micro use:

VDU 2  To turn printer on

VDU 3  To turn printer off

Standard PRINT statement will work with printer as well as screen when VDU 2 is used to turn printer on.

MODE


MODE n

Result: Selects display mode. (BBC Micro & Acorn Electron)

The following modes are available:

MODE 0 - 640x256 Two colour display, 80x32 text
MODE 1 - 320x256 Four colour display, 40x32 text
MODE 2 - 160x256 16 colour display, 20x32 text
MODE 3 - Two colour 80x25 text only
MODE 4 - 320x256 Two colour display, 40x32 text
MODE 5 - 160x256 Four colour display, 20x32 text
MODE 6 - Two colour text only, 40x25 text
MODE 7 - Teletext display, 40x25 text (BBC Micro only)

The ZX Spectrum has only one display 'mode' 256x176 8 colour with 2 levels of brightness, 32x22 text (these figure do not include the 'INPUT' area at the bottom of the screen).



MOVE

(Acorn Electron & BBC Micro Statement)


MOVE x,y

Result: Moves graphics cursor to a particular absolute position without drawing a line. (BBC Micro & Acorn Electron)

To move the graphics cursor on the ZX Spectrum without plotting use:

POKE 23677,x

POKE 23678,y

Note: The MOVE statement as used by the BBC & Electron is completely different to the MOVE command used by the ZX Spectrum with Interface 1 and Microdrive to manipulate files.

See also DRAW, PLOT (BBC Micro & Acorn Electron), PLOT (ZX Spectrum).

OPEN #

(ZX Spectrum)


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)

ZX Spectrum
On the Spectrum the hash symbol after OPEN is not a single character but part of the OPEN # keyword.

For the equivalent Acorn Electron and BBC Micro functions see: OPENIN, OPENOUT, OPENUP.

See also CLOSE #.

OUT


OUT m,n

Result: Outputs byte n to port m.
ZX Spectrum
Not on the Acorn Electron or BBC Micro as the 6502 processor is memory mapped for I/O devices.

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.

ZX Spectrum
Not on the Electron or BBC. 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 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;


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.

ZX Spectrum
On the Acorn Electron and BBC Micro the COLOUR and GCOL statements are used to set foreground and background colours in modes 0 to 6.

In MODE 7 on the BBC Micro colours are set with control codes.

See also COLOUR, GCOL, INK, VDU.

PAUSE


PAUSE n

Result: Stop program execution for n*1/50seconds or until a key is pressed.
ZX Spectrum
On the ZX Spectrum PAUSE 0 is not timed but lasts until a key is pressed. The Electron and BBC Micro have no PAUSE statement. The easiest solution would be to use a REPEAT...UNTIL loop.

PLOT

(BBC Micro & Acorn Elcetron)


PLOT k,x,y

Result: Plots to the point at X,Y. Result depends on value of k. (BBC Micro & Acorn Electron)

0 - Move relative to last point.
1 - Draw line relative in the current graphics foreground colour.
2 - Draw line relative in the logical inverse colour.
3 - Draw line relative in the current graphics background colour.
4 - Move to absolute position.
5 - Draw line absolute in the current graphics foreground colour.
6 - Draw line absolute in the logical inverse colour.
7 - Draw line absolute in the current graphics background colour.
8-15 As 0-7 but with the last point in the line omitted.
16-23 As 0-7 but with a dotted line.
24-31 As 0-7 but with a dotted line and without the last point on the line.
32-63 Reserved.
64-71 As 0-7 but only a single point is plotted.
72-79 As 0-7 but to draw a horizontal line to the left and right of the point until a colour other than the current background colour is reached.
80-87 As 0-7 but plot and fill a triangle.
88-95 As 0-7 but to draw a horizontal line to the right until reaching the current background colour.
96-255 Reserved.

Similar to PLOT and DRAW on the Spectrum but with extra options for dotted lines and filled triangles.

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).

ZX Spectrum
See also CIRCLE, DRAW, PLOT (BBC Micro & Acorn Electron).

POKE

(ZX Spectrum)



?  (Question Mark)

(Acorn Electron & BBC Micro)




POKE m,n  (ZX Spectrum)

?m=n  (Acorn Electron & BBC Micro)

Result: Load byte n into memory address m.
ZX Spectrum
The question mark (?) used on the Acorn machines is actually called a Byte Indirection Operator but it does work just like POKE.

See also: Indirection operators, PEEK.

PRINT


PRINT ...

Result: Send a series of items to the display subject to control characters and AT/TAB (and TAB/INK/PAPER/INVERSE/FLASH/OVER on the ZX Spectrum).

ZX Spectrum
Similar on both micros with exceptions.

See also AT, TAB.

PROC


PROCprocedure_name[(α1[,...,αk])]  (BBC Micro & Acorn Electron)

Result: Calls a procedure previously defined by DEF PROC. α1 to αk can be a single letter or two more more letters followed by $ for a string argument or result.

Not on the ZX Spectrum, GO SUB should be used in lieu of PROC.

Simple named procedures can be structured on the Spectrum by defining a named variable as the line number of the 'procedure'. Care must be taken if renumbering a program which contains variables storing line numbers.

See also GO SUB, DEF PROC...END PROC.

RANDOMIZE


RANDOMIZE  (ZX Spectrum)

RANDOMIZE n  (ZX Spectrum)

Result: Sets system variable SEED to n which will be the basis for pseudo-random numbers (RND).
ZX Spectrum
On the BBC and Electron use:

RANDOMIZE=RND(-n+1)

Where RANDOMIZE is a dummy variable and n must not be zero.

Note: ZX Spectrum keyboard shows shortened RAND and not RANDOMIZE.

See also RND.

READ


READ e1,e2,e3, ...

Result: Read from DATA statement and pass to a variable or variables e1,e2,e3, ..

ZX Spectrum
Similar on both micros with exceptions.

REM


REM ...

Result: None, display comment in program listing.

ZX Spectrum
Same result all round.

REPORT


REPORT  (No operands)

Result: Print a report on screen of the last error.

On the ZX Spectrum there is a system variable called ERR NR which resides at address 23610 and holds the current error number. It is not possible to use this from BASIC as once the error is displayed 255 is put into ERR NR. 255 represents the error:

0 OK, line:statement

See also: ERL, ERR, ON ERROR.

RESTORE


RESTORE

Result: Restores DATA pointer to start of program.



RESTORE n

Result: Restores DATA pointer to line n.

ZX Spectrum
Same result all round.

See also DATA, READ.

RETURN


RETURN

Result: Take line number off GO SUB stack and GO TO the line after that line number.

ZX Spectrum
Same result all round.

See also GOSUB/GO SUB, ON GOSUB.

SOUND


SOUND C,A,P,D  (BBC Micro & Acorn Electron)

Result: Generates a sound.

C is the channel number 0 to 3 (0=white noise, 1-3=pure notes)
A is the amplitude or loudness 0 (off) to -15 (loudest)
P is the pitch 0 to 255
D is the duration 1 to 255 (each step is a quarter semi-tone with Middle C at 52)



BEEP may be used on the Spectrum to simulate one SOUND channel only.

This can be done by taking the pitch subtracting 4, dividing by 4 then subtracting 12. The duration is calculated by dividing it by 20.

So:

SOUND c,a,p,d

can be translated as:

BEEP d/20,((p-4)/4)-12

Where p is the pitch, d is the duration, a is the volume, and c is any one of the channels from 1 to 3 bearing in mind that a 16/48K Spectrum can only play one channel at a time at a fixed volume.

The Spectrum 128K models can play up to 3 channels at once with variable volume with the PLAY statement.

See also: ADVAL, BEEP, ENVELOPE.

STOP


STOP

Result: Stops program execution with Report 9.  (ZX Spectrum)

Result: Stops program execution with error report.  (Acorn Electron & BBC Micro)

The error reports are as follows:

9 STOP statement, line:statement  (ZX Spectrum)

STOP at line line  (Acorn Electron & BBC Micro)

ZX Spectrum
Similar on both micros.

Electron and BBC STOP statement works exactly like END but unlike END will produce a report.

The ZX Spectrum may be able to resume execution with CONTINUE.

See also CONTINUE, END.

TAB


PRINT TAB(m);  (ZX Spectrum)

INPUT TAB(m);  (ZX Spectrum)

Result: Print spaces from current PRINT position up to column m.



PRINT TAB(m[,n]);  (BBC Micro & Acorn Electron)

INPUT TAB(m[,n]);  (BBC Micro & Acorn Electron)

Result: Prints spaces from current text cursor position up to column m.
If a second parameter is giving start printing (or input message) from column m on row n.

The ZX Spectrum's TAB statement does not support a second parameter, instead AT must be used.

See also AT, INPUT, SPC.

VDU


VDU n(,|;n)[;]  (BBC Micro & Acorn Electron)

Result: Generates characters or control codes.

Same as:

PRINT CHR$(n)[+CHR$(n1)][...+CHR$(nk)][;]

On the Spectrum use:

PRINT CHR$ n[+CHR$ n1][...+CHR$ nk][;]

This will only work for ASCII codes and some control codes.

See also CHR$.

WIDTH


WIDTH n  (BBC Micro & Acorn Electron)

Result: Sets the page width that the computer uses, affects screen and printer. By default set to zero which is interpretted as unlimited width.

On the ZX Spectrum+ 128K, ZX Spectrum +2 and the ZX Spectrum +3 the width setting of the printer is set in the system variables at memory location 23396.


Compound & Structured Statements

Keyword

Meaning

Comments

DEF FN

(BBC Micro & Acorn Electron)


DEF FNα[(α1,[...,αk])]

    [multi-line expressions go here]

=value to be returned  (BBC Micro & Acorn Electron)

Result: Defines a function. α1 to αk can be a single letter or two more more letters followed by $ for a string argument or result. If there are no arguments then brackets must not be used.

The equals sign '=' produces the result of the function and passes control back to the line from which the function was called.

The ZX Spectrum cannot define a function over multiple lines.

See also DEF FN (Statement), FN.

DEF PROC...ENDPROC

(BBC Micro & Acorn Electron)


DEF PROCprocedure_name[(α1[,...,αk])]

    [multi-line expressions go here]

END PROC  (BBC Micro & Acorn Electron)

Result: Defines a procedure. α and α1 to αk can be a single letter or two more more letters followed by $ for a string argument or result.

Not on the ZX Spectrum, GO SUB should be used in lieu of PROC.

Simple named procedures can be structured on the Spectrum by defining a named variable as the line number of the 'procedure'. Care must be taken if renumbering a program which contains variables storing line numbers.

See also GO SUB, PROC.

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 [α]  (BBC Micro & Acorn Electron)

Result: Sets up and executes the loop α from x to y with a step of z.

[Note] Step of +1 assumed if STEP omitted).

On the BBC Micro and Acorn Electron the control variable after NEXT is optional.

The BBC Micro & Acorn Electron allow long names in varables and integer variables, the Spectrum only allow one character variable names for control variables.

ZX Spectrum
Same result all round.

Although the NEXT statement is not compounded within the FOR statement as TO and STEP are, it is included here for completeness.

IF..THEN

(BBC Micro & Acorn Electron and ZX Spectrum)


IF..THEN..ELSE

(BBC Micro & Acorn Electron)


IF x THEN s  (BBC Micro & Acorn Electron and ZX Spectrum)

Result: If x is true (non-zero) then s will be executed.


IF x THEN line number  (BBC Micro & Acorn Electron)

Result: If x is true (non-zero) then continue program execution from line number.


IF x THEN s1 ELSE s2  (BBC Micro & Acorn Electron)

Result: If x is true (non-zero) then s1 will be executed, otherwise s2 will be executed..
ZX Spectrum
ELSE can be simulated on the ZX Spectrum by skipping the line immediately after the IF..THEN if the condition is true.

IF condition THEN statement : GO TO
next_statement

else_statement

next_statement

ON...

ON...GOTO

ON...GOSUB

ON ERROR...


ON x GOSUB¦GOTO m1 [,m2...,mk][ELSE s]

Result: Branch to line m if x is true else execute statement s.

ON ERROR s¦OFF

Result: On error branch execute statement s or turn off error trapping.

The ZX Spectrum can simulate ON..GOTO/GOSUB with

GO TO (m1 AND x=1)+(m2 AND x=2)+
(mk AND x=k)

REPEAT...UNTIL


BBC Micro & Acorn Electron - Short Form

REPEAT [statement(s)] UNTIL condition




BBC Micro & Acorn Electron - Long form

REPEAT

    statements

UNTIL condition


Result: Sets up and executes a REPEAT loop and performs statements. UNTIL closes the loop.

Not on the ZX Spectrum but a REPEAT loop to wait for a keypress can be achieved with the following code.

LET exit=1

FOR r=0 TO 0 STEP 0

IF INKEY$<>"" THEN LET r=exit

NEXT r

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 REPEAT.

Next comes the line which checks for a keypress. If true r, the REPEAT loop variable, will be set to exit or 1, and the loop will be exited at NEXT r

NEXT r completes the loop, this is the eqivalent of UNTIL.


Functions

Keyword

Meaning

Comments

ABS


ABS x  (ZX Spectrum)

ABS(x)  (BBC Micro & Acorn Electron)

Returns: Absolute magnitude of x, i.e. distance on number line from zero, -1=1 -2=2
ZX Spectrum
Same result all round.

ACS


ACS x  (ZX Spectrum)

ACS(x)  (BBC Micro & Acorn Electron)

Returns: Arccosine (inverse cosine) of x in radians.
ZX Spectrum
Same result all round.

ADVAL


ADVAL(n)  (BBC Micro & Acorn Electron)

Returns: Number of free spaces in sound buffer.

n=-8 to n=-5 correspond to SOUND channels 0 to 3 respectively.

There is no equivalent function to ADVAL on the ZX Spectrum.

ASC


See CODE

ASN


ASN x  (ZX Spectrum)

ASN(x)  (BBC Micro & Acorn Electron)

Returns: Arcsine (inverse sine) of x in radians.
ZX Spectrum
Same result all round.

ATN


ATN x  (ZX Spectrum)

ATN(x)  (BBC Micro & Acorn Electron)

Returns: Arctangent (inverse tangent) of x in radians.
ZX Spectrum
Same result all round.

ATTR


ATTR (x,y)

Returns: numeric value between 0 and 255 of the attribute at position x,y.
ZX Spectrum
Not on the BBC Micro or Acorn Electron. See the POINT (BBC Micro & Acorn Electron) function which performs a similar task to the Spectrum's ATTR and POINT functions.

See also POINT.

CHR$


CHR$ x  (ZX Spectrum)

CHR$ (x)  (BBC Micro & Acorn Electron)

Returns: Single character from position x in the character set.
ZX Spectrum
Although the CHR$ function performs the same task on both Acorn and Sinclair computers the end result may be different.

The BBC, Electron and Spectrum micros use a character set based on ASCII. The BBC Micro uses a slightly different character set (still based on ASCII) for MODE 7 (Teletext).

See also VDU

CODE  (ZX Spectrum)

ASC  (BBC Micro & Acorn Electron)


CODE α$  (ZX Spectrum)

ASC (α$)  (BBC Micro & Acorn Electron)

Returns: Numeric value (between 0 and 255) representing the position in the character set of α$. (This is the inverse of the CHR$ function)

If null string zero is returned (ZX Spectrum) or -1 (BBC Micro & Acorn Electron)
ZX Spectrum
Although the CODE / ASC function performs the same task on both computers, just like CHR$ above, the end result may be different.

COUNT


COUNT  (BBC Micro & Acorn Electron)

Returns: The number of characters printed since the last new line. COUNT is set to zero if the output stream is changed.

There is no equivalent function to COUNT on the ZX Spectrum.

DEG


DEG(n)  (BBC Micro & Acorn Electron)

Result: Converts and angle of n radians to degrees.

Not on the Spectrum but easily reproduced with the following function:

DEF FN d(n)=n*180/PI

where n is the angle in radians.

See also RAD

EOF#


EOF#(channel) 

Returns: zero if there is more data or -1 if the end of file has been read. (BBC Micro & Acorn Electron).

Not on the Spectrum or ZX Interface 1. ZX Interface 1 has its own way to read end of file.

ERL


ERL (no operands)

Returns: Line number where the last error occurred. (BBC Micro & Acorn Electron).

Not on the Spectrum.

See also ERR, ON ERROR, REPORT.

ERR


ERR (no operands)

Returns: The last error that occurred. (BBC Micro & Acorn Electron).

On the Spectrum the last error which occured is stored in the system variable ERR NR at address 23610. This is not easily accessible from BASIC.

See also ERL, ON ERROR, REPORT.

EVAL


See VAL, VAL$.

EXP


EXP x  (ZX Spectrum)

EXP(x)  (BBC Micro & Acorn Electron)

Returns: Numeric value for the function ex where e=2.7182818....
ZX Spectrum
Same result all round.

EXT#


EXT#(channel) 

Returns: Size of file in opened channel in bytes. (BBC Micro & Acorn Electron - Econet and disc systems only).

No equivalent function on the Spectrum.

FN


FN α([α1[,...,αk]])  (ZX Spectrum)

Result: Calls a user defined function. α and α1 to αk can be a single letter or single letter followed by $ for a string argument or result and must match that defined by DEF FN. Brackets are obligatory even if there are no arguments i.e. FN α()

FNα[(α1, αk)]  (BBC Micro & Acorn Electron)

Result: Calls a user defined function. α and α1 to αk can be a single letter or two more more letters followed by $ for a string argument or result. If there are no arguments then brackets must not be used.

ZX Spectrum
On the BBC Micro and Electron there is no space between 'FN' and the function name.

See also DEF FN (Statement), DEF FN (Structured Statement).

GET


GET  (no operands)

Returns: ASCII code from input stream after waiting for a key press (BBC Micro & Acorn Electron).

Not on the Spectrum.

This function can be simulated with a short subroutine:

1000 REM **GET KEY PRESS**

1010 PAUSE 0

1020 LET k$=INKEY$

1030 IF k$="" THEN GO TO 1010

1040 LET GET=CODE k$

1050 RETURN

The subroutine is called with a GO SUB to line 1000 and uses the string variable k$ to temporarily store the ASCII character relating to the key which has just been pressed. The function CODE is then applied to k$ to obtain the character's ASCII code, this is then stored is the variable GET.

See also GET$, INKEY, INKEY$.

GET$


GET$  (no operands)

Returns: ASCII character after waiting for a key press (BBC Micro & Acorn Electron).

Not on the Spectrum.

This function can be simulated with a short subroutine:

1000 REM **GET KEY PRESS 2**

1010 PAUSE 0

1020 LET k$=INKEY$

1030 IF k$="" THEN GO TO 1010

1040 RETURN

The subroutine is called with a GO SUB to line 1000 and uses the string variable k$ to temporarily store the ASCII character relating to the key which has just been pressed. This is almost the same routine that is used to simulate GET and if required it would be better to use that one as it will simulate GET and GET$.

See also GET$, INKEY, INKEY$.

IN


IN m

Returns: numeric value between 0 and 255 for the port m.

ZX Spectrum
Not on the Acorn Electron or BBC Micro as the 6502 processor is memory mapped for I/O devices.

INKEY


INKEY(n)  (BBC Micro & Acorn Electron)

Returns (if n is positive): ASCII code after waiting n1/100ths of a second for a key press or -1 if no key is pressed (BBC Micro & Acorn Electron).

Returns (if n is negative): -1 is key denoted by n is press otherwise zero.

The key press codes for n if n is negative are as follows:

f0 -33, f1 -114, f2 -115, f3 -116, f4 -21, f5 -117, f6 -118, f7 -23, f8 -119, f9 -120

A -66, B -101, C -83, D -51, E -35, F -68, G -84, H -85, I -38, J -70

K -71, L -87, M -102, N -86, O -55, P -56, Q -17, R -52, S -82, T -36

U -54, V -100, W -34, X -67, Y -69, Z -98

1 -49, 2 -50, 3 -18, 4 -19, 5 -20, 6 -53, 7 -37, 8 -22, 9 -39, 0 -40

- -24, ^ -25, \ -121, @ -72, [ -57, _ -41, ; -88, : -73, ] -89, ’ -103

. -104, / -105, Space bar -99, ESCAPE -113, TAB -97, CAPS LOCK -65 CTRL -2, SHIFT LOCK -81, SHIFT -1, DELETE -90, COPY -106, RETURN -74 CURSOR UP-58, CURSOR DOWN -42, CURSOR LEFT-26, CURSOR RIGHT -122

Not on the Spectrum.

When n is positive this function can be simulated with a short subroutine:

1000 REM **INKEY(n)**

1010 PAUSE n*2

1020 LET k=CODE INKEY$

1030 RETURN

The subroutine is called with a GO SUB to line 1000. A PAUSE of n*2 and not n is required as the ZX Spectrum waits for 1/50ths of a second and not 1/100ths like the Acorn computers. The ASCII code of the key pressed the held in the variable k.

See also GET, GET$, INKEY$.

INKEY$


INKEY$ (no operands) (ZX Spectrum)

Returns: Single character from a keypress.


INKEY$(n) (BBC Micro & Acorn Electron)

Returns: Single character from a keypress after waiting n1/100ths of a second.

ZX Spectrum
Similar result all round.

For the Spectrum a PAUSE of n1/100ths of a second can be placed before INKEY$ with:

PAUSE n*2

LET a$=INKEY$

See also GET, GET$, INKEY.

INSTR


INSTR(position,α$,β$)

Returns: The position for the first occurrence of β$ in α$ beginning at position. Returns zero if no match is found. (BBC Micro & Acorn Electron).

Not on the Spectrum. A short subroutine can be written to perform the same task.

INT


INT x  (ZX Spectrum)

INT(x)  (BBC Micro & Acorn Electron)

Returns: x rounded down to a lower integer.

ZX Spectrum
Mostly the same result on each micro with the exception that occurs on the ZX Spectrum when INT -65536 is performed (the wrong result is given as -1).

See also ABS, SGN.

LEFT$


LEFT$(α$,m)  (BBC Micro & Acorn Electron)

Result: Returns first m characters of α$.

On the Spectrum LEFT$ can be emulated with the TO string slicing facility:

LET β$=α$( TO m)

See also MID$, RIGHT$, TO.

LEN


LEN α$  (ZX Spectrum)

LEN(α$)  (BBC Micro & Acorn Electron)

Returns: numeric value for the length of α$.

ZX Spectrum
Same result all round.

LN


LN x  (ZX Spectrum)

LN(x)  (BBC Micro & Acorn Electron)

Returns: numeric value for the natural logarithm of x.
ZX Spectrum
Same result all round.

See also EXP, ↑, ^.

LOG


LOG(x)  (BBC Micro & Acorn Electron)

Returns: numeric value for the common logarithm to base 10 of x.

Not on the Spectrum.

A function can be defined to perform the same task:

DEF FN l(x)=LN x/LN 10

See also EXP, LN, ↑, ^.

MID$


MID$(α$,m[,n])  (BBC Micro & Acorn Electron)

Result: Returns the n characters of α$, starting at position m. If n is omitted the entire string to the right of m is returned. m must be greater than zero.

On the Spectrum MID$ can be emulated with the TO string slicing facility:

LET β$=α$(m TO m+n-1)

See also LEFT$, RIGHT$, TO.

OPENIN


v=OPENIN(s$)

Result: Opens a file for input to computer (from cassette, disc or Econet) and returns the channel number allocated by the computer’s filing system. If the file does not exist zero is returned.  (BBC Micro & Acorn Electron)

For the ZX Spectrum equivalent see OPEN #.

See also OPENOUT, OPENUP

OPENOUT


v=OPENOUT(s$)

Result: Opens a file for output to cassette, disc or Econet and returns the channel number allocated to the output file.   (BBC Micro & Acorn Electron)

For the ZX Spectrum equivalent see OPEN #.

See also OPENIN, OPENUP

OPENUP


v=OPENUP(s$)

Result: Opens a file for update and returns the channel number allocated it.  (BBC Micro & Acorn Electron)

For the ZX Spectrum equivalent see OPEN #.

See also OPENIN, OPENOUT

POINT


POINT (x,y)

Returns: 1 if pixel is on or 0 if it is off for the pixel location x,y. (ZX Spectrum)

POINT(x,y)

Returns: number representing a colour at screen location x,y or -1 if x or y are off the screen (BBC Micro & Acorn Electron).
ZX Spectrum
Since the ZX Spectrum stores pixels in its memory seperate from the colour attributes POINT will only return whether a pixel is on or off. To acheive a similar result to the BBC/Electron ATTR could be used instead or as well as POINT.

See also ATTR

POS


POS (no operands)

Returns: The position of the flashing screen cursor.
On the Spectrum we can use:

LET pos=33-PEEK 23688

or for the lower screen:

LET posl=33-PEEK 23690

The addresses 23688 and 23690 refer to the system variables SPOSN and SPOSNL respectively.

See also VPOS.

RAD


RAD(n)  (BBC Micro & Acorn Electron)

Result: Converts and angle of n degrees to radians.

Not on the Spectrum but easily reproduced with the following function:

DEF FN r(n)=(n/180)*PI

where n is the angle in degrees.

See also DEG.

RIGHT$


RIGHT$(v$,m)

Result: Returns last m characters of v$.

On the Spectrum RIGHT$ can be emulated with the TO string slicing facility:

β$=α$(LEN α$-m+1 TO )

See also LEFT$, MID$ (Function), TO.

RND


RND  (ZX Spectrum, BBC Micro & Acorn Electron)

Result: A pseudo-random number between 0 and 1 (ZX Spectrum).

Result: A random whole number between -2147483648 and 2147483647 (BBC Micro & Acorn Electron).



RND(-x)  (BBC Micro & Acorn Electron)

Result: Returns the value -x and resets the random number generator to a number based on x.



RND(0)  (BBC Micro & Acorn Electron)

Result: Returns the last random number generated by RND(1)



RND(1)  (BBC Micro & Acorn Electron)

Result: Generates a random number between 0 and 0.999999.



RND(x)  (BBC Micro & Acorn Electron)

Result: Generates a random whole number between (and possibly including) 1 and x.

ZX Spectrum
There are quite a few differences between the RND function on the BBC and Electron and RND on the ZX Spectrum so to summerise:

The BBC/Electron's

RND

can be simulated on the ZX Spectrum with:

INT-(RND*2147483648)+2147483647



also on the BBC and Electron

RND(-x)

The above function not only returns the number placed into it (i.e. -x) but also resets the random number generator based on -x. This is similiar to how the RANDOMIZE statement works on the ZX Spectrum:

RANDOMIZE x

Note: Notice x is positive on the ZX Spectrum as the Sinclair machine will not allow a negative number for RANDOMIZE (Prefix x with ABS if necessary).



RND(0)

just repeats the last random number given by RND(1) which is similar to:

(PEEK 23670+256*PEEK 23671)/65536

on the Spectrum.



RND(1)

on the Acorn micros is the same as the Spectrum's:

RND



...and finally

RND(x)

on the Acorns is just like the Spectrum's:

INT(RND*x)+1


See also RANDOMIZE.

SCREEN$


SCREEN$ (x,y)

Returns: character displayed at location x,y.

ZX Spectrum
Not on the Acorn Electron or BBC Micro.

SGN


SGN x  (ZX Spectrum)

SGN(x)  (BBC Micro & Acorn Electron)

Returns: signum (or sign) of x, for instance -1 if x<0, 0 if x=0 or 1 if x>1.

ZX Spectrum
On the BBC & Electron brackets are obligatory.

SIN


SIN x  (ZX Spectrum)

SIN(x)  (BBC Micro & Acorn Electron)

Returns: Sine of x in radians.

ZX Spectrum
Same result all round.

See also COS, TAN, ASN, ACS, ATN.

SPC


PRINT SPC(n);  (BBC Micro & Acorn Electron)

INPUT SPC(n);  (BBC Micro & Acorn Electron)

Result: Prints a multiple amount of spaces (n).

n can be 0 to 255.

Not on the ZX Specrum but a quick and simple way to simulate SPC would be to define a dimensional string array and slice the number of spaces required.

For example:

DEF FN s$(n)=s$( TO n)

DIM s$(255)

PRINT FN s$(20);

would print 20 spaces.

Strictly speaking the definable function is not required but it does look and work more like SPC than just using the string slicing method on its own:

s$( TO n)

with one desirable side effect being that if n=0 there will be no error when using FN, but a 'Subscript Error' will occur if you use just standard string slicing.

After DIM no other setting up is required as all newly defined string arrays default to blank spaces (CHR$ 32). This is not very memory efficient though as 255 memory locations are required just to set up s$ with spaces.

See also INPUT, PRINT, STRING$, TAB.

SQR


SQR x  (ZX Spectrum)

SQR(x)  (BBC Micro & Acorn Electron)

Returns: square root of x.

If x<0 then the following errors will occur:

A Invalid Argument, line:statement  (ZX Spectrum)

-ve root  (BBC Micro & Acorn Electron)

ZX Spectrum
Same on result all round.

STR$


STR$ x  (ZX Spectrum)

STR$(x)  (Acorn Electron & BBC Micro)

Result: string comprising of the numeric value of x.

ZX Spectrum
Same result all round.

See also EVAL, VAL.

STRING$


STRING$(m,a$)

Result: Returns a string of a$ characters of length m.  (Acorn Electron & BBC Micro)

Not on the Spectrum.

A short subroutine could be written to simulate STRING$.

See also SPC.

TAN


TAN x  (ZX Spectrum)

TAN(x)  (BBC Micro & Acorn Electron)

Returns: Tangent of x in radians.

ZX Spectrum
Same result all round.

See also ACS, ASN, ATN, COS, SIN.

USR


USR m  (ZX Spectrum)

Returns: contents of the bc register pair after calling machine code at memory location m.

v=USR(m)  (BBC Micro & Acorn Electron)

Returns: contents of the A, X, Y and P registers after calling machine code at memory location m.
ZX Spectrum
The ZX Spectrum will return the value of the bc register pair (Z80). The Acorn Electron and BBC Micro machines return the A (Accumulator), X, Y and P (Flags) registers.

Note: For comparison only. Z80 and 6502 machine language subroutines are totally incompatible with each other and must be completely rewritten to accomodate the machine the code is being ported to.

See also CALL.

USR


USR α$

Returns: location in memory of user defined graphic α$.
ZX Spectrum
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.

On the Acorn Electron and BBC Micro user-defined graphics are created by using the VDU statement.

See also VDU.

VAL

(ZX Spectrum and BBC Micro & Acorn Electron)

EVAL

(BBC Micro & Acorn Electron)



VAL f$  (ZX Spectrum)

Result: Evaluates f$ as a number or numeric expression.



EVAL(f$)  (BBC Micro & Acorn Electron)

Result: Evaluates f$ as a number or numeric expression.



VAL(f$)  (BBC Micro & Acorn Electron)

Result: Converts f$ to a number. f$ must begin with plus (+), minus (-) or a number or zero is returned.

ZX Spectrum
On the Spectrum when evaluating a string containing a numeric expression and not a another string VAL performs the same task as both EVAL and VAL on the BBC and Electron.

Note the difference of use of the BBC and Electron's EVAL and VAL functions. The former will evaluate numbers and numeric expressions which may or may not contain variables or numeric functions, wheras the latter will only evaluate numbers.

EVAL can also evaluate string expressions like the Spectrum's VAL$ (see below).

See also STR$, VAL$.

VAL$

(ZX Spectrum)

EVAL

(BBC Micro & Acorn Electron)



VAL$ f$  (ZX Spectrum)

EVAL(f$)  (BBC Micro & Acorn Electron)

Result: Evaluates f$ as a string expression.

ZX Spectrum
Evaluating a string on the BBC/Electron using EVAL is very similar in use to the ZX Spectrum's VAL$ function.

BBC Micro/Acorn Electron code:

B$="TEST"

A$="B$"

PRINT EVAL(A$)

ZX Spectrum code:

LET b$="TEST"

LET a$="b$"

PRINT VAL$ a$

See also VAL.

VPOS


VPOS  (no operands) (BBC Micro & Acorn Electron)

Returns: Vertical position of text cursor.

Not on the Spectrum but

24-PEEK 23689

will do the same thing.

Memory location 23689 is the location for the second part of the system variable S POSN.

See also POS.


Pseudo-variables

Keyword

Meaning

Comments

HIMEM


HIMEM  (BBC Micro & Acorn Electron)

Returns: Address of the highest byte in RAM.

Result: Sets the address of the highest memory location in RAM.

Not on the Spectrum. For the Spectrum equivalent of variable=HIMEM use variable=PEEK 23732+256*PEEK 23733. Addresses 23732 and 23733 contain the system variable P-RAMT.

See also CLEAR (command), LOMEM, PAGE, TOP.

LOMEM


LOMEM  (BBC Micro & Acorn Electron)

Returns: The place in memory above which the BASIC interpreter stores dynamic variables.

Result: Sets the place in memory above which the BASIC interpreter stores dynamic variables.

Not on the Spectrum. For the Spectrum equivalent of variable=LOMEM use variable=PEEK 23627+256*PEEK 23628. Addresses 23627 and 23628 contain the system variable VARS.

See also HIMEM, PAGE, TOP.

PAGE


PAGE  (BBC Micro & Acorn Electron)

Returns: The memory location where BASIC stores the user's program.

Result: Sets the place in memory where BASIC stores the user's program.

Not on the Spectrum. For the Spectrum equivalent of variable=PAGE use variable=PEEK 23635+256*PEEK 23636. Addresses 23635 and 23636 contain the system variable PROG.

See also HIMEM, LOMEM, TOP.

TOP


TOP  (BBC Micro & Acorn Electron)

Returns: Address of the first byte that BASIC does not use.

Result: Sets the address of the first byte that BASIC does not use.

Not on the Spectrum. The CLEAR command performs a similar function to TOP=address. For the Spectrum equivalent of variable=TOP use variable=PEEK 23730+256*PEEK 23731. Addresses 23730 and 23731 contain the system variable RAMTOP.

See also CLEAR (command),HIMEM, LOMEM, PAGE.

TIME


TIME  (no operands) (Acorn Electron & BBC Micro).

Returns: amount of time in 1/100secs intervals since computer was switched on or counter was set to zero.



TIME=n  (Acorn Electron & BBC Micro)

Result: Sets the timer to zero or another time.

On the ZX Spectrum use :

65636*PEEK 23674+256*PEEK 23673+PEEK 23672

To reset clock use:

POKE 23674,0 : POKE 23673,0 : POKE 23672,0

The Spectrum updates the internal clock every 1/50 of a second.


Constants

Keyword

Meaning

Comments

FALSE


FALSE  (BBC Micro & Acorn Electron)

Returns: The numerical equivalent of zero.

Not on the Spectrum. Can be replaced in a program simply with :

0  (zero!)

or by defining a variable in lieu of a FALSE constant.

LET FALSE=0

See also TRUE.

PI


PI

PI requires no operands.

Returns: 3.1415927 (ZX Spectrum)

or

3.13159265 (BBC Micro & Acorn Electron)

(π) Ratio of circumference of a circle to its diameter

Typical usage might be:

LET R=C/(2*PI)

ZX Spectrum
PI (π) is stored on the Spectrum as 10 digits but will only display 8 digits.

TRUE


TRUE  (BBC Micro & Acorn Electron)

Returns: The numerical equivalent of minus one (-1).

Not on the Spectrum. Can be replaced in a program simply with :

-1  (See note)

or by defining a variable in lieu of a TRUE constant.

LET TRUE=-1

Note: In most cases can just be replaced with '1' but check context of program first.

See also FALSE.


Operators

Keyword

Meaning

Comments

-

Unary Minus/Negation


-x

Result: negates x.

ZX Spectrum
Same result all round.

-

Binary Minus/Subtraction


x-y

Result: a numeric value resulting from y being subtracted from x.

ZX Spectrum
Same result all round.

+

Addition


x+y

Result: a numeric value resulting from y being added to x.

ZX Spectrum
Same result all round.

+

String concatenation


α$+β$

Result: concatenates (joins together) string α with string β to form a new string.

ZX Spectrum
Same result all round.

/

Division


x/y

Result: a numeric value resulting from x being divided by y.

ZX Spectrum
Same result all round.

*

Multiplication


x*y

Result: a numeric value resulting from x being multiplied by y.

ZX Spectrum
Same result all round.

↑ or ^

Raise to the power of


x↑y  (ZX Spectrum & BBC Micro MODE 7)

x^y  (Acorn Electron & BBC Micro MODE 0 to 6)

Result: a numeric value resulting from x being raised to the power of y.

ZX Spectrum
On the Acorn Electron & BBC Micro, to give the correct result when x is negative the equation -x↑y requires that the base (the -x part) is enclosed in brackets.

i.e. (-x)^y

This technique will not work 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

See also EXP.

<

Less than


x<y

Where x and y can be either numeric or strings but cannot be mixed.

Result: 1 if x<y otherwise 0 (ZX Spectrum)

Result: -1 if x<y otherwise 0 (Acorn Electron & BBC Micro).

ZX Spectrum
Similar result. See note 1.

>

Greater than


x>y

Where x and y can be either numeric or strings but cannot be mixed.

Result: 1 if x>y otherwise 0 (ZX Spectrum)

Result: -1 if x>y otherwise 0 (Acorn Electron & BBC Micro).

ZX Spectrum
Similar result. See note 1.

<=

Less than or 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 (ZX Spectrum)

Result: -1 if x≤y otherwise 0 (Acorn Electron & BBC Micro).

ZX Spectrum
Similar result. See note 1.

>=

Greater than or 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 (ZX Spectrum)

Result: -1 if x≥y otherwise 0 (Acorn Electron & BBC Micro).

ZX Spectrum
Similar result. See note 1.

=

Variable assignment


LET x=y  (ZX Spectrum)

[LET] x=y  (Acorn Electron & BBC Micro)

Where x and y can be either numeric or strings but cannot be mixed.

Result: x is assigned the value y.

ZX Spectrum
Same result all round.

=

Is 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 (ZX Spectrum)

Result: -1 if x=y otherwise 0 (Acorn Electron & BBC Micro).

ZX Spectrum
Similar result. See note 1.

<>

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.

ZX Spectrum
Similar result. See note 1.

~  (tilde)

(Acorn Electron & BBC Micro)


÷  (divide sign)

(BBC Micro MODE 7 only)


~x  (BBC Micro & Acorn Electron)

÷x  (BBC Micro MODE 7 only)

Result: Hexadecimal value of decimal number x.

Not on the Spectrum but could be reproduced with a function or subroutine.

On the BBC Micro in MODE 7 ~ (tilde) is replaced by ÷ (divide).

See also &, BIN.

&  (ampersand)

(Acorn Electron & BBC Micro)


&h  (BBC Micro & Acorn Electron)

Result: Decimal value of hexadecimal number h

Not on the Spectrum but could be reproduced with a function or subroutine.

See also ~, BIN.

AND


x AND y

Where x is a number or a string, and y is always numeric.  (ZX Spectrum)

Where x and y are both numeric or x and y are both testable conditions.  (BBC Micro & Acorn Electron)

Returns: x if y is true (non-zero) or 0 if y is false (zero)  (ZX Spectrum).

Result : A bitwise calculation of x and y. Bits in x and y are compared. If bits in both x and y are 1 then the resulting bit after performing a bitwise AND will be 1 otherwise it will be 0. Testable conditions will return either -1 (true) or 0 (false)

  (BBC Micro & Acorn Electron)

ZX Spectrum
A short machine code routine could simulate bitwise AND on the ZX Spectrum.

A similar result may occur on both the Spectrum and the Acorn Electron/BBC Micro.
See note 2.

BIN


BIN b

Returns: decimal value of a base2 (binary) 16 bit number.

ZX Spectrum
Only on Spectrum. Not strictly a function but a numerical notation.

A short subroutine could easily be coded to simulate this function on the Acorn machines.

See also ~ and &.

DIV


DIV y  (BBC Micro & Acorn Electron)

Result: An integer divsion of x divided by y.

Not on the Spectrum but easily reproduced with the following function:

DEF FN d(x,y)=INT(x/y)

where x is the numerator and y is the denominator.

See also INT, MOD.

OR


x OR y

Where x and y are both numeric.

Returns  (ZX Spectrum): 1 if x or y≠0, value of x if y=0.

Result  (BBC Micro & Acorn Electron): A bitwise calculation of x and y. Bits in x and y are compared. If bits in either x or y are 1 then the resulting bit after performing a bitwise OR will be 1 otherwise it will be 0.

ZX Spectrum
A similar result may occur on both the Spectrum and the Acorn Electron/BBC Micro.
See note 2.

MOD


m MOD n

Returns: Modulus (remainder) of m divided by n.
The modulus can be found on the Spectrum with the function:

DEF FN M(m,n)=INT(m-(INT(m/n)*n))

See also DIV, INT.

NOT


NOT x

Where x is numeric.

Returns : zero if x≠0, 1 if x=0  (ZX Spectrum).

Result: A bitwise reversal of x. Bits in x are reversed; 0 becomes 1, 1 becomes 0.  (BBC Micro & Acorn Electron)

ZX Spectrum
A similar result may occur on both the Spectrum and the Acorn machines.

In the event of a problem converting from one machine to the other the following code may help:

To convert the ZX Spectrum's 'Boolean NOT' use the following code on the BBC Micro or Acorn Electron:

x=ABS(x=0)

To convert from BBC/Electron to the Spectrum use this code:

LET x=-x-1

EOR


m EOR n

Where m and n are both numeric.

Result: Performs logical or bitwise Exclusive-OR between m and n.
Logical EOR (or XOR on most other computers) does not exist on the Spectrum but this can be coded in BASIC as follows.

DEF FN X(x,y)=(x OR y) AND  
NOT (x AND y)


Indirection Operators

Keyword

Meaning

Comments

?  (Query or Question Mark)

(Acorn Electron & BBC Micro)


?m=n  (Acorn Electron & BBC Micro)

Result: Load byte n into memory address m (like POKE).



v=?m  (Acorn Electron & BBC Micro)

Result: Read byte from memory address m and place in variable v (like PEEK).



PRINT ?m  (Acorn Electron & BBC Micro)

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.

!  (Shriek or Exclamation Mark)

(Acorn Electron & BBC Micro)


!m=n  (Acorn Electron & BBC Micro)

Result: Load word n to memory starting at address m.



v=!m  (Acorn Electron & BBC Micro)

Result: Read word from memory m0 to m3 and place in variable v.



PRINT !m  (Acorn Electron & BBC Micro)

Result: Read word from memory address m0 to m3 and display.

The word m is read from memory little-endian style.

Not to be confused with integer variables i.e. m!

On the Spectrum we can load a 4 byte word to memory with:

POKE m,n-INT (n/256)*256

POKE m+1,INT (n/256)

POKE m+2,INT (n/65536)

POKE m+3,INT (n/16777216)

And we can read a 4 byte word from memory with:

PEEK m+(PEEK (m+1))*256+(PEEK (m+2))*65536+(PEEK (m+3))*16777216

See also: PEEK, POKE.

$  (Dollar sign)

(Acorn Electron & BBC Micro)


$m=v$  (Acorn Electron & BBC Micro)

Result: Write v$ to memory starting at memory location m (a carriage return 0Dh or CHR$ 13 is added to the end of v$).



v=?m  (Acorn Electron & BBC Micro)

Result: Read byte from memory address m and place in variable v (like PEEK).



PRINT ?m  (Acorn Electron & BBC Micro)

Result: Read byte from memory address m and display (like PEEK).

Not to be confused with string variables i.e. v$

On the ZX Spectrum this should work for writing a string to memory:

LET v$=v$+CHR$ 13

FOR α=1 TO LEN v$

POKE m-1+f,v$(α)

NEXT α

And this subroutine for reading from memory to a string:

1000 LET v$=""

1010 IF PEEK m=13 THEN RETURN

1020 LET v$=v$+CHR$ PEEK m

1030 LET m=m+1

1040 GO TO 1010


Delimiters

Keyword

Meaning

Comments

TO


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).
ZX Spectrum
Not on the Acorn Electron or BBC Micro.

For the equivalent string slicing statements see LEFT$, MID$ and RIGHT$.

;

Semi-colon


PRINT ;  (ZX Spectrum, Acorn Electron & BBC Micro)

LPRINT ;  (ZX Spectrum only)

INPUT ;  (ZX Spectrum)

INPUT message;v  (ZX Spectrum, Acorn Elecron & BBC Micro)

VDU m,n1,n2;n3  (Acorn Electron & BBC Micro)

Result: separates items within a PRINT, LPRINT (ZX Spectrum only) or INPUT statement.

message is text within double quotes. v is a numeric or string variable.

A number which follows a semi-colon within a VDU statement will be a double byte number  (Acorn Electron & BBC Micro).

ZX Spectrum
Similar usage all round.

'

Apostrophe


PRINT '  (ZX Spectrum, Acorn Electron & BBC Micro)

LPRINT '  (ZX Spectrum only)

INPUT '  (ZX Spectrum only)

Result: Moves the PRINT (or LPRINT) position down a line.
ZX Spectrum
Similar usage all round.

,

Comma


as a PRINT item


PRINT ,  (ZX Spectrum, Acorn Electron & BBC Micro)

LPRINT ,  (ZX Spectrum only)

INPUT ,  (ZX Spectrum, Acorn Electron & BBC Micro)

Result: 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.

ZX Spectrum
ZX Spectrum INPUT comma works, just like the PRINT comma, by moving the PRINT position 15 characters along.

,

Comma


as an operand/parameter delimiter


Examples:

MOVE x,y  (Acorn Electron & BBC Micro)

ATTR (x,y)  (ZX Spectrum)

Result: Separates operands/parameters within a statement.

ZX Spectrum
Mostly the same all round.

#

Hash


PRINT #m  (ZX Spectrum)

PRINT#m  (Acorn Electron & BBC Micro)

LPRINT #m  (ZX Spectrum only)

INPUT #m  (ZX Spectrum)

INPUT#m  (Acorn Electron & BBC Micro)

ZX Spectrum
Similar result on each micro. Some statements on the ZX Spectrum may require the ZX Interface 1.

:

Colon


s1 : s2 : s3 ...

Result: Allows more than one statement per line number to be entered.
ZX Spectrum
Same result all round.

"

Single quotation marks


α$="some text"  (ZX Spectrum, Acorn Electron & BBC Micro)

PRINT "some text"  (ZX Spectrum, Acorn Electron & BBC Micro)

LPRINT "some text"  (ZX Spectrum)

INPUT "some text"  (ZX Spectrum)

Result: Encloses text within a string or within a PRINT, INPUT or LPRINT statement (LPRINT is on ZX Spectrum only).
ZX Spectrum
ZX Spectrum can store a single quote within a set of quotation marks like so

""some text""

produces the output:

"some text"

For the same result on the Electron and BBC use the character code CHR$(34), for instance:

PRINT CHR$(34);"some text";CHR$(34)

or for a string variable

α$=CHR$(34)+"some text"+CHR$(34)



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
e represents an expression
f represents a string valued expression
h represents a hexadecimal number
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)
BBC Microcomputer User Guide, John Coll (author), David Allen (editor), 1984
Acorn Electron User Guide, Acorn Computers Ltd (publisher), June 1983

Notes

[1] Due to the way the Acorn machines make logical comparisons they will always return -1 if true whereas the Spectrum will return +1. This should not be a problem when converting code between machines but should a problem be encountered use ABS result on the Spectrum to negate the positive result or
-result on the Acorn Electron/BBC Micro to negate the -1 and make it positve.

[2] Whether the result is correct or not will depend on the context of the program.
If the flow of the program only requires boolean logic then converting programs between machines should not cause many problems. However, if a logical 'bitwise' result is required then this is not possible with standard Sinclair BASIC and machine code should be used to return the desired result.

External Links

ZX Spectrum manual for download at World of Spectrum.
BBC Micro User Guide - BBC Lives!  (Robert Schmitt's Homepage)
Acorn Electron User Guide at retro 8-bit computers



Last revision : 03/04/2024