8 bit


Of late, I’ve picked up an interest in the CLR through learning C#. After being impressed by the performance of the .NET runtime (less so for Mono, although that’s another story) I decided that an effective way to really get to grips with the system would be to write a compiler which targets the CLR.

During a nostalgic poke around the web relating to Acorn hardware, over 12 years since my last contact with BBC BASIC, I stumbled across Richard Russell’s BBC BASIC for Windows (BB4W) which reminded me of my formative years learning to code on the BBC Model B and later various Acorn Archimedes computers under RISC OS. This led me to start down the road of implementing a BBC BASIC compiler for the CLR, although the original BBC BASIC, and BB4W are interpreted. The original BBC BASIC II resided in only 16 kB of ROM, so it can’t be that much work. Can it?

The BBC Basic for Windows implementation, from Russell actually goes to long lengths to provide good backwards compatibility with software originally developed for the Beeb or RISC OS, such as providing a Teletext MODE 7 equivalent, and ‘emulated’ sound and graphics support.

I will be taking a different tack with this project. Rather than focus on getting old code reliant on obsolete hardware features to run, I will focus on making a viable BBC BASIC compiler for the CLR, which could be used to port existing programs to .NET/Mono. It is likely that OS or machine specific functionality such as sound and graphics will be implemented in significiantly different ways compared to the originals, for example, by giving good language-level integration with the System.Console class in .NET, rather than trying to emulate screen modes from Acorn hardware.

The toolset I settled on is as follows:

  • IronPython in which to write the compiler
  • PLY - the Python Lex/Yacc-a-like
  • BeebEm - BBC Micro emulator with BBC BASIC II
  • Arculator - Acorn Archimedes emulator with BBC BASIC V
  • Documentation in the form of BBC Micro and Archimedes user manuals, and various other information and examples on the web

Mostly its an experiment, and for the fun of writing a compiler. I don’t expect anybody to start creating large software systems in BBC BASIC as a result of my efforts. Far from it; there are much better tools today. However, I must admit to a secret aim of producing the fastest BBC BASIC implementation yet!

BBC Computer 32K
The BBC Model B computer. The computer was bought by my father in 1984 using some money which he received from the death of his father. I was nine years old. This was our grandfather’s legacy for us. That single purchase for £400 in Beatties department store in Wolverhampton 21 years ago changed my life greater than any other single purchase made before or since. It wholly responsible for my career since that time.

In terms of the hardware of the time, the BBC Microcomputer was something special. It had 32 kB of RAM for programs and the display and 32 kB of ROM containing the operating system and BBC BASIC, occupying the 64 kB address space of the 6502 CPU. We had a somewhat unreliable cassette deck for storing programs.

I probably spent thousands of hours over the next four years learning to program, mostly in the fantastic BBC BASIC (real prodecures with parameters, REPEAT..UNTIL loops and no real need to use GOTO, and of course integrated 6502 assembler) which gave me an excellent grounding in structured, procedural programming. I had a good line in writing software for my father to help in his land and engineering surveying work, which was my first introduction to writing mathematical and engineering software - all in BBC BASIC.

I also spent time fiddling with the hardware side of things, very much encouraged by the massive expandability of the BBC Micro. Usuually this would involve connecting home-made devices, motor controllers and the like, to the User Port (pretty raw access to a 6522 VIA chip) or to the Analogue Port. All of this was inspired by a series of articles by Mike Cook in The Micro User (later Acorn Computing) Magazine called The Beeb Body Building Course.

So why the nostalgia?

Well, two reasons. The first is that this early exposure computing is largely responsible for my career path, and the fact today that I now work as a software developer. The second reason is that last week I downloaded an impressively good BBC Micro emulator for my PC called BeebEm.

Obviously, a BBC emulator isn’t much use to me these days for software development, and all the interesting hardware aspects of the Beeb are of course not relevant. Nonetheless, it did give me the opportunity to indulge in some serious nostalgia playing old games such as Thrust, Elite and Exile.