As part of the work I’ve been doing with cpmish I’ve been trying to track down the copyright holders of some of the more classic pieces of CP/M software and asking them to license it in a way that allows redistribution. One of the people I contacted was R.T. Russell, the author of the classic Z80 BBC BASIC, and he very kindly sent me the source and agreed to allow it to be distributed under the terms of the zlib license. So it’s now open source!

I’ve made the 37-year-old source build and added it to the cpmish respository; it works fine and is shipping with the cpmish disk images.

The Z80 BBC BASIC source This is a direct link to the source code, if you want to look at it or download it. You'll need a CP/M syntax assembler to turn it into a binary; there's one integrated into the cpmish distribution. Precompiled binaries continue to be available from R.T.Russell's web site). Note that this source is the generic CP/M version and none of the graphics or sound instructions work. (They're stubbed out and can be implemented if anyone wishes.)

So the reason why this is important is that BASIC has, rightly, a reputation for being a pretty terrible language; but BBC BASIC was a dialect specifically commissioned by the BBC in 1981 as an educational aid. As a result, BBC BASIC supports named procedures, local variables, recursion, and other structured programming features. Unlike Microsoft BASIC, you can write proper structured, maintainable programs in BBC BASIC without needing to refer to any line numbers anywhere. And it’ll run faster that way:

10 PRINT FNfactorial(5) 20 END 30 : 40 DEF FNfactorial(n) 50 IF n=0 THEN =1 60 =FNfactorial(n-1) * n

It had tight integration with the BBC MOS operating system, which a decent set of graphics and file primitives, meaning you could write complex programs in it very easily; it was blisteringly fast; and most intriguingly, it was also an extremely powerful macro assembler…

10 DIM mc 100: REM allocate 100 bytes of storage 20 FOR pass=0 TO 3 STEP 3: REM two pass assembly 30 P%=mc: REM set destination address 40 [OPT pass: REM start assembler mode 50 : 60 .print_q 70 LDA #ASC("q") 80 JSR &FFEE : REM OSWRCH, write character to screen 90 RTS 100 ]:NEXT 110 : 120 REM Assembly complete, run machine code program! 130 CALL print_q

The original version was written by Sophie Wilson at Acorn in 1981 for their 6502-based range of BBC Micro computers and during the early eighties every school child in the United Kingdom was exposed to it, spawning a whole generation of bedroom programmers.

R.T. Russell then wrote an independent implementation for the Z80, running on CP/M, which was sold commercially; it was ported to many different machines (such as my Amstrad NC200 laptop!), as well as being shipped by Acorn with their Z80 addon for the BBC Micro. There’s a full history on Russell’s web site, including the 8086 and Windows versions (which remain commercial products, although Russell has a open source extended BBC Basic for various other platforms).

This version behaves very nearly identically to the 6502 version, and comes complete with the assembler — a Z80 one, of course. The differences and operating system interface are documented with the source, but the language reference itself has to be accessed online. Or, if you prefer, you can use Acorn’s own documentation as it’s the same language.