BBC BASIC

From Wikipedia, the free encyclopedia

BBC BASIC
BBC micro assembly listing.jpg
First appeared1981; 40 years ago (1981)
Stable release
5.90b
OSBBC Micro
MOS Technology 6502
RISC OS
ZX Spectrum
CP/M
DOS
Microsoft Windows
TI-83 Plus & TI-84 Plus
LicenseApache 2.0 (RISC OS)
Proprietary (Windows)
Websitewww.riscosopen.org (RISC OS)
www.bbcbasic.org (Windows)
Influenced by
BASIC, Atom BASIC, BCPL

BBC BASIC is a version of the BASIC programming language released in 1981 as the native programming language for the BBC Micro home/personal computer, providing a standardized language for a UK computer literacy project of the BBC.[1] It was written mainly by Sophie Wilson.

BBC BASIC, based on the older Atom BASIC for the Acorn Atom, extended contemporary microcomputer BASICs with named DEF PROC/DEF FN procedures and functions, REPEAT UNTIL loops, and IF THEN ELSE structures inspired by COMAL. The interpreter also included statements for controlling the BBC Micro's four-channel sound output and its low-/high-resolution eight-mode graphics display.

Due to a number of optimizations, BBC BASIC ran programs much faster than Microsoft BASIC running on similar machines. The optimizations included using multiple linked lists for variable lookup rather than a single long list, pre-defining the location of integer variables, and having separate integer maths routines. Speed was further improved on the BBC machine via the use of fast RAM, which allowed the MOS Technology 6502 processor and Motorola 6845 display driver to share memory without pausing for access.[a] As a result of these design features, BBC BASIC ran David Ahl's Creative Computing Benchmark in 21 seconds, besting even the IBM Personal Computer, and far outpacing most other 8-bit platforms.[2] The only commercial 8-bit BASIC computers that were as fast as the BBC Micro were the Swedish ABC 80 and ABC 800. The improved BASIC 4 on the BBC Master executes the same benchmark in about seven seconds.[citation needed]

One of the unique features of BBC BASIC was the inline assembler, allowing users to write assembly language programs for the 6502 and, later, the Zilog Z80, NS32016 and ARM. The assembler was fully integrated into the BASIC interpreter and shared variables with it, which could be included between the [ and ] characters, saved via *SAVE and *LOAD, and called via the CALL or USR commands. This allowed developers to write not just assembly language code, but also BASIC code to emit assembly language, making it possible to use code-generation techniques and even write simple compilers in BASIC.

History[]

In 1978 Hermann Hauser and Chris Curry founded Acorn Computers. Much of the code was developed at Cambridge University by Sophie Wilson[3] and her colleagues.[4]

Platforms and versions[]

BBC Micro[]

BASIC prompt on the BBC Micro after switch-on or hard reset

The full version list is available here: [5]

BASIC I, the original version, was shipped on early BBC Micros.

BASIC II was used on the Acorn Electron and BBC Micros shipped after 1982, including the Model B. It added the OPENUP and OSCLI keywords, along with offset assembly and bug fixes.

BASIC III, was produced in both a UK version and a United States market version for Acorn's abortive attempt to enter the cross-Atlantic computer market. Apart from a few bug fixes, the only change from BASIC II was that the COLOUR command could also be spelled COLOR: regardless of which was input, the UK version always listed it as COLOUR, the US version as COLOR. The main place that BASIC III can be found is as the HI-BASIC version for the external second processor.

BASIC IV, also known as CMOS BASIC, available on the BBC Master machines, was changed to use the new instructions available in the 65SC12 processor, reducing the size of the code and therefore allowing the inclusion of LIST IF, EXT# as a statement, EDIT, TIME$, ON PROC, | in VDU statements and faster floating point. Bug fixes were again included.

BASIC IV(1986) was a further improvement to BASIC IV, and was included on the Master Compact machine. The version of BASIC on the Compact included re-coded mathematical routines, said to provide a 30% speed increase over the version included in the rest of the Master series.[6]

HI-BASIC: this was available in two versions, the first based on BASIC III, and the second based on BASIC IV. Both were built to run from a higher address (&B800) on the second processor, rather than the usual &8000 address on the BBC B. This allowed more program space to be available on either the external or internal 6502 Second Processors. A version was introduced to support a second Zilog Z80 processor.[7]

Another version of BBC BASIC, called BAS128, was supplied on tape and disc with the BBC Master and Master Compact; it loaded into main RAM and used the 64 kB of Sideways RAM for user programs. This provided support for much larger programs at the cost of being a lot slower than the normal ROM-based version.

The interpreter can deal with both BASIC and 6502 assembly language, which can be included between the [ and ] characters. This contributed to the system's popularity with industrial and research engineers.[8]

Further details/Determining BASIC version[]

As the BBC MOS and RISC OS were usually supplied on ROM, it may be assumed that a specific release of the operating system contained a specific version of BASIC. As such, there is no simple way to determine which version of BASIC is actually running other than by enquiring the operating system identity and thus making an assumption.

Note that all Electrons, and later BBC microcomputers, have BASIC2: the earlier BBC microcomputers have BASIC1. If you are not sure which version of BASIC is in your machine, typing REPORT after BASIC has started up (after a BREAK or *BASIC), will print the copyright message. If the date is 1981, BASIC1 is fitted; if it is 1982, you have BASIC2. American machines, or those with a second processor, may have US BASIC or HIBASIC: the ROM routines will not be in the same place for these ROMS.
— BASIC ROM USER GUIDE
Osbyte &00(0)

Identify OS version (See OSBYTE &81 for more information regarding OS identification)

Entry parameters:
X=0 Execute BRK with a message giving the OS version
X<>0 RTS with OS version returned in X

On exit:
X=0, OS 1.00 or Electron OS 1.00
X=1, OS 1.20 or American OS


Osbyte &81(129)
Entry parameters:
X=0
Y=&FF

On exit:
X=0 BBC OS 0.1
X=1 Electron OS 1.00
X=&FF BBC OS 1.00 or OS 1.20
X=&FE US BBC OS 1.20


INKEY(-256) command
Examples, to avoid the *SHADOW command upsetting a standard Electron or BBC model B, whilst executing it on a B+ or Master/Compact, you could use
IF INKEY(-256)>1 THEN *SHADOW1

Returned values:
0 = BBC B with old 0.10 OS (obsolete!)
-1 = BBC B with new 1.00+ OS (including 1.20)
1 = Electron
251 = BBC B+ 64/128
253 = Master 128
245 = Compact
160 = Archimedes Arthur OS (obsolete)
161 = RISC OS 2.00
162 = RISC OS 2.01

etc.
— Acorn Electron Advanced User Guide

See also BeebWiki entry for INKEY.

On the BBC family, it is possible to run both the standard BASIC and an enhanced HIBASIC on the 6502 Second Processor. One may determine if the program is running on the second processor by examining the initial value of PAGE, it will be &800 if using the second processor. To distinguish between BASIC and HIBASIC, one should examine the initial value of HIMEM. This will be &8000 for BASIC running on the second processor, and &B800 for HIBASIC on the second processor.

A similar situation exists on RISC OS where there may be the normal BASIC or BASIC64 (which offers higher precision maths). Normal BASIC identifies itself as "BASIC V" and BASIC64 identifies itself as "BASIC VI", therefore the following (used before any error has occurred) will distinguish one from the other:

IF INSTR(REPORT$,"VI") THEN PRINT "BASIC64" ELSE PRINT "BASIC"

There are better ways of doing this, see the BeebWiki. In almost all cases you shouldn't need to be testing for what BASIC or platform your program is running on, just make the call and read whatever returned data is returned and deal with it.

Acorn Archimedes (RISC OS)[]

With the move to the 32-bit ARM CPU and the removal of the 16 KB limit on the BASIC code size many new features were added.[9] BASIC V version 1.04 was 61 KB long. Current versions of RISC OS still contain a BBC BASIC V interpreter. The source code to the RISC OS 5 version of BBC BASIC V has been released under the Apache 2.0 license by RISC OS Open.[10] In 2011 released test versions of an updated BASIC which includes support for VFP/NEON from assembler.[11]

Amongst the new commands and features supported were:

  • WHILE-ENDWHILE
  • IF-THEN-ELSE-ENDIF
  • CASE-OF-WHEN-OTHERWISE-ENDCASE,
  • RETURN parameters in procedures,
  • local arrays,
  • procedure libraries (LIBRARY,INSTALL and OVERLAY),
  • LOCAL DATA and LOCAL ERROR handlers,
  • a relative RESTORE,
  • array operations,
  • new operators,
  • STEP TRACE,
  • Commands for the new sound system, mouse, graphics.

The graphics commands were entirely backwards compatible, the sound less so; for example, the ENVELOPE keyword from BASIC V onwards is a command that takes fourteen numeric parameters and effectively does nothing— as in older versions, it calls OS_Word 8, but that does nothing on RISC OS.[12][13] The in-line 6502 assembler was replaced by an ARM assembler. BASIC V was said, by Acorn, to be "certainly the fastest interpreted BASIC in the world" and "probably the most powerful BASIC found on any computer".

BASIC VI is a version of BASIC V that supports IEEE 754 8-byte format real numbers, as opposed to the standard 5-byte format introduced in BASIC I.

BBC BASIC V and VI were delivered as standard on the Acorn Archimedes and the RiscPC. A version of BBC BASIC V was also available to run on the ARM second processor for the BBC Micro.

A compiler for BBC BASIC V was produced by Paul Fellows, team leader of the Arthur OS development, called the Archimedes BASIC Compiler and published initially by DABS Press.[citation needed] ABC was able to implement almost all of the language, with the obvious exception of the EVAL function, which inevitably required run-time programmatic interpretation. As evidence of its completeness, it was able to support in-line assembler syntax. The compiler was written in BBC BASIC V. The compiler (running under the interpreter in the early development stages) was able to compile itself, and versions that were distributed were self-compiled object code.[original research?] Many applications initially written to run under the interpreter benefitted from the performance boost that this gave, putting BBC BASIC V on a par with other languages for serious application development.

Other platforms[]

BBC BASIC has also been ported to many other platforms.[14]

A NS32016 version of BBC BASIC was supplied with the Acorn 32016 coprocessor and Acorn ABC.

In addition to the version of BBC BASIC supplied with the BBC Micro's Zilog Z80 Second processor, a Z80-based version of BBC BASIC also exists for CP/M-based systems. Until recently, no version existed for the Sinclair ZX Spectrum; however, due to efforts of J. G. Harston (also responsible for a PDP-11 version[15]), BBC BASIC for the Spectrum was released in January 2002, with many improvements made in subsequent releases.

A Zilog Z80 version of BBC BASIC was also used on the Tiki 100 desktop computer, Cambridge Z88 portable and the Amstrad NC100 Notepad and Amstrad NC200 Notebook computers. This version has been implemented on the TI-83 Plus and TI-84 Plus series graphing calculators.

For PC-based systems, BBC BASIC was also implemented for DOS as BBCBASIC (86), which aimed for maximum compatibility with the BBC Micro, and BBasic, which concentrated on the BASIC language, with its own enhancements based on BASIC II.

A version of BBC BASIC integrated with the Microsoft Windows graphical user interface, BBC BASIC for Windows created by Richard Russell, developer of the Z80 and x86 versions, was released in 2001. This version is still under active development, seeing much industry use currently. Whilst supporting nearly completely the original BBC BASIC specification (BASIC IV), the Windows version supports much of BASIC V/VI syntax as well as some advanced features of its own. Features unique to BBC BASIC for Windows include interpreter support for record/structure types, and the ability to call Windows API routines or those in an external DLL. Recent versions have included advanced features comparable with languages like C, and an external library has recently added support for objects. An SDL based version of BBC BASIC is available on Windows, Linux and a number of mobile devices supporting the SDL library.

A GPL clone of BBC BASIC named Brandy, written in portable C, is also available.[16][17][18][19][20]

An emulator of the BBC Micro for the Commodore Amiga was produced by Ariadne Software for CBM (UK). While extremely fast, it did not emulate the 6502 at full speed, so assembly code would run slower than a real BBC while BASIC programs would run much faster. Due to the way the optimised BASIC and the 6502 emulation interacted, almost no commercial games would run (but well behaved code and educational software generally worked); additionally it used a slightly less precise floating-point numeric format. For a while it was bundled with a special academic package of the Amiga 500, in the hope that schools would replace their ageing BBC Bs with Amiga 500s.

BBC Micro publishing house Computer Concepts produced a version of BBC Basic for the Atari ST, named , as a ROM cartridge.[21]

A version of BBC BASIC V (Z80) has also been made for the TI-83/84+ Texas Instruments calculator families by Benjamin Ryves.

A Commodore 64 version Shado was produced by a small software house in the early 1980s.[22]

Notes[]

  1. ^ On most machines of the era, the processor spent as much as 30% of its available time waiting on memory.

See also[]

  • Dot space

References[]

  1. ^ "BBC Micro ignites memories of revolution". BBC News. 21 March 2008. Retrieved 28 November 2010.
  2. ^ Ahl, David (March 1984). "Creative Computing Benchmark". Creative Computing. p. 6.
  3. ^ "Video processor for Acorn/BBC computer". BBC News. Retrieved 30 November 2010.
  4. ^ "BBC Micro ignites memories of revolution". BBC News. 21 March 2008. Retrieved 30 November 2010.
  5. ^ BBC BASIC version list
  6. ^ Acorn User October 1986 — page 17{ — Master Compact Review
  7. ^ Smith, Bruce (November 1984). A & B Computing. 1, Golden Square London: Argus specialist Publications. p. 6.CS1 maint: location (link)
  8. ^ Marsh, David (5 December 2005). "ARM targets automotive and industrial dominance". EDN Europe. Retrieved 1 August 2012.
  9. ^ Roger Wilson (3 July 1989). "BASIC V 1.02 versus 1.04 changes (for Richard LLoyd!)". Newsgroupeunet.micro.acorn. Usenet: 807@acorn.co.uk. Retrieved 14 June 2011.
  10. ^ https://gitlab.riscosopen.org/RiscOS/Sources/Programmer/BASIC/-/blob/master/LICENSE
  11. ^ Lee, Jeffrey (2 August 2011). "Have I Got Old News For You". The Icon Bar. Retrieved 8 December 2011. TBA software have been keeping themselves busy by releasing a test version of an updated BBC BASIC with VFP/NEON assembler support.
  12. ^ http://lists.cloud9.co.uk/pipermail/bbc-micro/2006-November/000257.html
  13. ^ http://mdfs.net/Archive/BBCMicro/2006/11/19/185014.htm
  14. ^ BBC BASIC - MDFS::Software.$.BBCBasic
  15. ^ BBC BASIC for PDP-11
  16. ^ Williams, Chris (6 December 2003). "BASIC V for Unix, DOS, Windows and RISC OS: We talk to author Dave Daniels about the spirit of Brandy BASIC". Drobe. Retrieved 6 July 2011. Brandy BASIC is a BASIC V interpreter that has been compiled for RISC OS, NetBSD/arm32, NetBSD/i386, Linux, DOS and Windows.
  17. ^ Daniels, Dave. "Brandy Basic". RISC World. Retrieved 6 July 2011. Brandy is a portable interpreter for BBC Basic, that is to say, it allows programs written in BBC Basic to be developed and run on computers other than ones running RISC OS.
  18. ^ "Brandy". Archived from the original on 17 July 2011. Retrieved 6 July 2011.
  19. ^ "Brandy Basic V Interpreter". Retrieved 6 July 2011.
  20. ^ "Matrix Brandy BBC Basic V with SDL and Teletext for Linux". Retrieved 4 August 2018.
  21. ^ "Fast BASIC by Computer Concepts". RetroGames.
  22. ^ http://mdfs.net/Software/BBCBasic/C64/

External links[]

Retrieved from ""