www.riscos.com Technical Support:
This appendix is designed to pinpoint the variations found among the dialects of BBC BASIC. You can use it to determine whether a given feature of the language is present in a particular version. You should also refer to Appendix B: Minimum Abbreviations. This gives the version number of the first appearance of each keyword. For example, OSCLI has II in the version column, as the OSCLI statement was first introduced in BASIC II.
There have been six releases of BBC BASIC, the latest being BASIC VI. The complete list is:
The original version supplied with early BBC Microcomputers, models A and B. BBC BASIC is in turn descended from Atom BASIC, a fast integer-only BASIC supplied with the Acorn Atom.
This was an update to BASIC I. It also ran on the BBC models A and B. It incorporated various bug fixes to BASIC I, and added the OPENUP and OSCLI keywords, and offset assembly. Version II is the principal BBC Microcomputer version of BBC BASIC.
This was supplied on the BBC Microcomputer model B+. It was substantially unchanged from version II. There were one or two bug fixes, and a new keyword: the American spelling of the COLOR statement.
Also known as CMOS BASIC, this version was a major development from BASIC III. It was designed for use on the BBC Master series and 65C12 Second Processors. Both these used a slightly more powerful version of the 6502 processor than the one used in the original BBC. This allowed several major enhancements to be squeezed into the ROM, such as LIST IF, EXT# as a statement, EDIT, TIME$, ON PROC, | in VDU statements and faster floating point. Some bugs were also corrected.
Developed for Acorn RISC computers. BASIC V built on the foundations provided by BASIC IV. However, because of the lack of restrictions such as 16 KBytes total code size, the enhancements made were far greater than those that appeared previously. The interpreter was by now about 61 KBytes long, including comprehensive built-in help text, and was probably the most powerful BASIC found on any computer. It was certainly the fastest interpreted BASIC in the world.
This upgrade of the version 1.04 interpreter gave BBC BASIC more speed and power. New commands were introduced. The interpreter had grown to 64Kbytes to accommodate the improvements.
BASIC VI runs on the Acorn RISC computers. Improved floating point handling means it now performs floating point arithmetic to IEEE standard 754, using 8-byte real representation.
Because BASIC V is still a useful language, you are given the option to invoke either BASIC V (using the *BASIC command) or BASIC VI (using the new *BASIC64 command). The interpreter is now only 57 KBytes long, although the value of PAGE is higher.
OSCLI. This passes a string to the command line interpreter for execution. It is more powerful than simple * commands, as these cannot contain general string expressions.
OPENUP. This does an OSFIND with reason code &C0, i.e. open an existing file for update. This was the action of OPENIN in BASIC I. OPENIN now does an OSFIND &40, i.e. open for input only. OPENOUT still does an OSFIND &80, i.e. create and open for update.
Numeric printing has been improved to allow numbers to be printed to ten digits accuracy. This allows integers up to 233 to be printed without resorting to 'E' notation.
The MODE statement now resets the COUNT function to zero.
A semi-colon (;) is allowed in place of a comma (,) in the INPUT statement.
Fatal errors are introduced. These have error number 0, and cause an automatic ON ERROR OFF. This means that the default error handler is always used for these errors. The STOP statement now causes a fatal error, as does the No room condition. Additionally, the standard error handler no longer uses stack space, so spurious No room errors are not produced.
A new error, number 45, Missing # is given if any of the keywords PTR, EOF, BGET, BPUT, EXT is not followed by a #.
String allocation has been improved. A string which was the last one created on the heap can be extended without discarding the old storage. This stops No room errors from being generated in certain situations.
Bit 2 of the assembler OPT expression is used to control offset assembly. If this bit is set, P% holds the run-time location counter, and O% holds the assembly-time counter where bytes are actually assembled to. If bit 2 is clear, P% holds both the run-time and assembly-time counters.
Four new assembler directives are introduced: EQUB, EQUW, EQUD, EQUS. These allow one-, two-, four- and multiple-byte (string) quantities to be embedded into the code.
ELSE in an ON GOTO/GOSUB no longer leaves a byte on the 6502 stack. This prevented ELSE from being used in ON statements in BASIC I.
INSTR no longer leaves the main string on the software stack when it is shorter than the substring. This caused ENDPROC and =expression to crash when INSTR was used inside a PROC or FN under the above-mentioned condition.
The argument of EVAL is now tokenised correctly so that EVAL"TIME" (or any other pseudo-variable) works. Previously the statement versions of pseudo-variables were used, resulting in a No such variable error when BASIC tried to evaluate the expression.
The ABS function can now cope with non-negative integers without returning a string type. Previously, ABS1 appeared to yield a string so a statement like PRINT -ABS1 would give a type-mismatch error.
The LN and LOG functions have been re-written. This makes them more accurate and avoids a problem when BASIC tried to evaluate LN(2E-39). Other changes to the arithmetic package are a fix to a bug which caused INT1E39 to fail and the re-coding of the SIN/COS routine to make it more accurate.
A bug associated with ON ERROR GOTO 9999 (and other line numbers) has been fixed.
DIM var n where n is an expression less than -1 now gives a Bad DIM error instead of lowering the value of the free space pointer. This former action could result in the corruption of variables or the program.
The COLOUR keyword may now be spelt COLOR, to aid the porting of programs from American dialects of BASIC. In programs, the keyword always lists as COLOUR, except in the American version of BASIC III, which always lists it as COLOR. This is the only difference between the two versions.
A string expression in a SAVE command works correctly now, so you can say, for example, SAVE A$+B$ without error.
The indirection operators ? and ! may be used as formal parameters without problems. For example, you could have a procedure DEF PROCa(!&70), where the contents of locations &70..&73 act as a local integer variable.
The ON GOTO/GOSUB STATEMENT HAS BEEN EXTENDED TO INCLUDE PROCS. THE SYNTAX IS ON EXPRESSION PROCA_ PROCB_ PROCC [ELSE statement]. The nth PROC in the list is called, where n is the value of expression.
The EDIT command converts the program to text and then calls the editor with a *EDIT command. The program can be edited then re-tokenised by returning to BASIC. A No room error will be given if there is not enough room to store both the tokenised and textual version of the program during conversion to text.
The TIME$ pseudo-variable can be used to display and alter the time held in the CMOS battery-backed clock.
The delimiter | may be used in VDU statements to send nine 0 bytes after the last expression. This can be used to ensure that, for example, VDU 23 commands which require many trailing zeros are correctly terminated.
LISTO bits 1 and 2 (which cause loops to be indented) now work correctly, inasmuch as the NEXT lines up with its FOR and UNTIL with its REPEAT. If LISTO is non-zero, leading spaces are stripped from input lines (i.e. between the line-number and first statement). Trailing spaces are always stripped.
LIST has been extended by adding the IF part to it. LIST IFtext will only list lines which contain text.
The function EXT# returning the length of the file may now also be used as a statement to set the length of a file (EXT#chan=expr). It relies for its operation on an OSARGS call supported by ADFS and ANFS.
AUTO no longer prints a space after the line number, as this wasn't part of the input line anyway.
The assembler supports the full 65C12 instruction set, and now accepts lower case in all circumstances (e.g. the x in lda &70,x which previously had to be in upper case).
RENUMBER and LIST no longer get confused by the presence of an &8D Teletext control character in REM statements. (&8D is used in internal-format line numbers by BASIC).
In previous versions, a FOR loop which used an FN in the start, end or step expressions, where the FN itself contained a FOR loop would not work properly. This has been fixed.
The random number generator gives different results from previous versions for RND(1) and RND(n). This is to avoid certain statistical problems.
A bug whereby it was possible to RESTORE to a line which had no DATA statement but a comma present has been fixed.
This uses version 1.04 of the BASIC interpreter. Because the major part of the BASIC V guide is concerned with the documentation of BASIC V, this section only mentions the new keywords and features in very terse terms. You are directed to the Keywords chapters for detailed descriptions of all BASIC keywords. The index also gives you the page reference for the main discussion of topics mentioned below.
The new constructs WHILE ENDWHILE_ IF THEN ELSE ENDIF_ CASE OF WHEN OTHERWISE ENDCASE have been introduced. This makes readable, GOTO-less programming much easier to attain than previously.
Procedure and function calls have been enhanced in the following ways: value and result parameters (RETURN parameters), array parameters and local arrays, procedure libraries (LIBRARY, INSTALL and OVERLAY), LOCAL DATA and LOCAL ERROR handlers, a relative RESTORE statement which does not require the use of line numbers.
Many array operations have been introduced. These include: local arrays and array reference parameters, whole arrays operations such as assignment, four-function arithmetic, matrix and vector multiplication, SUM of array elements, the DIM function to find information on array parameters, array element initialisation, MOD (square root of the sum of the squares of a numeric array).
Several new operators have been introduced: << (left shift), >> (arithmetic right shift), >>> (logical right shift), | (floating point indirection), += (increment assignment, including all the elements of an array), -= (decrement assignment). The character % introduces binary constants as & introduces hexadecimal ones.
TRACE has been enhanced to allow single stepping and the tracing of procedure and function calls. Example: TRACE STEP PROC.
Line numbers may now be in the range 0-&FEFF, i.e. 0-65279. On line entry, BASIC checks for mismatched quotes and parentheses and attempts to reference line numbers greater than 65279. An error is reported if a mismatch is detected.
Attempts to set PAGE, LOMEM or HIMEM to incorrect values will result in an error message being printed, but execution will continue.
Many new statements have been introduced. The relevant keywords are: BEATS, BPUT#, CIRCLE, COLOUR, ELLIPSE, END, ERROR, EXT, FILL, GCOL, LINE, INPUT, LEFT$, MID$, RIGHT$, MOUSE, ON, OFF, ORIGIN, POINT, QUIT, RECTANGLE, SOUND, STEREO, SWAP, SYS, TEMPO, VOICE, VOICES, WAIT.
Several new functions have also been introduced. The keywords are: BEAT, BEATS, DIM, END, GET$#, LEFT$, MODE, REPORT$, RIGHT$, SUM, SUMLEN, TEMPO.
Some new commands have been introduced. They are: APPEND, HELP, LISTO (enhanced), LVAR, SAVE (enhanced), TWIN, TWINO. Additionally, the *BASIC command itself now supports several command-line options and arguments.
All error messages have been made more useful, and many new error messages have been introduced.
The assembler accepts the full ARM instruction set. Full details of the assembler are given in the Assembler Guide; a brief description is given in the appendix on the assembler in the Programmer's Reference Manual.
CALL and USR may be used to call ARM assembler routine, or to emulate 6502-based MOS routine when supplied with the appropriate addresses. Access to many internal BASIC routines is (legally) available to writers of CALL, USR and OSCLI routines. SYS can be used to access operating system SWI routines.
The default error handler sets @% to a value which ensures that the line number will be printed as an integer. It restores @% at the end.
COUNT and WIDTH are now stored as 32-bit wide quantities. This means that tabulation using commas is more reliable. (Strange effects used to occur after 255 characters had been printed.)
The pseudo-variables may now be used as statements after an IF even when the THEN is omitted. That is, IF relocate% PAGE=PAGE+&10000 will work, even though it didn't previously.
Integer FOR statements that would overflow will be ignored. (Basically this means that if limit+step-1 / &7FFFFFFF, the loop will terminate at the NEXT.)
This uses version 1.05 of the BASIC interpreter. It is an upgrade of BASIC V version 1.04, and includes new commands as well as bug fixes.
The new CRUNCH command strips various spaces from a program. Its argument is a 5-bit binary word. Each bit in the word has a different meaning (for instance bit 0 controls the stripping of spaces before statements; bit 2 controls the stripping out of REM statements).
END= can now be used almost anywhere, with the following exceptions: nested within EVAL or LOCAL ERROR; nested within assignments to local arrays; within nested local arrays.
The @% print formatter now uses ANSI G, E or F formats. If you use the 1.04 interpreter, you can achieve the same results using the method given in the description of the PRINT command.
The new TEXTLOAD command can load a file that is either a BASIC program, or a BASIC program that was saved as a text file. In the latter case, TEXTLOAD automatically renumbers the program. TEXTSAVE stores a BASIC program as a text file, and strips out the line numbers.
The TRACE command is now more versatile. Output from a TRACE command can now be sent to a file, using TRACE TO filename. TRACE can also be used as a function, to enable output other than line numbers to be sent to the trace file.
The speed of the following array statements has been increased:
foo()=<expression> foo%()=<expression> foo()=fie() DIM foo(, foo(, foo%
The interpreter now tags error messages with the name of the library which caused the error message (found from the REM statement on the first line of the library).
The interpreter can now handle such things as TAN1E-5.
PRINT -1^-10 will now print the value 1, instead of causing a crash.
There is now no difference between IF THEN ELSE and IF THENELSE.
This also uses version 1.05 of the BASIC interpreter. The major change for BASIC VI is that it now supports real numbers in 8-byte format (according to IEEE standard 754). This means greater precision and accuracy in floating point arithmetic.
BASIC VI can still understand 5-byte reals, but will only print numbers in the 8-byte real format.
Another change to note is that the name of this manual has changed to the BBC BASIC Reference Manual. The structure has also changed. In particular, the first two sections contain introductory and tutorial material, and the rest of the manual is given over to reference information. The sections on Keywords have been reorganised into one chapter, Keywords, which lists the keywords in alphabetical order.
BASIC VI is invoked using the new *BASIC64 command. BASIC V can still be invoked, by using the old *BASIC command. Both commands take the same command line options and arguments.
The interface of the CALL statement has changed to accommodate 8-byte reals. There are additions to the list of l-values to which R9 points.
INPUT# can now read variables in both 5-byte real format and 8-byte real format. PRINT# only prints numbers in 8-byte real format.