Just how did 8 bit computers like the ZX Spectrum or BBC Micro manage to cram an entire programming language into their tiny systems, and still have space for the user’s programs?
Let’s compare two systems of the time – the low end ZX Spectrum that tried to cram as much computer as possible into as little as possible, and the more luxurious BBC Micro that included a complete assembly programming environment.
In the 1980s software for home computers was either written in BASIC or written in assembly language. Unlike today where we can load an IDE, write our code on multiple monitors and then run and debug our compiled code with ease, the computers of the 1980s were stuck with running BASIC. That’s all there was, BASIC. Beginner’s All Purpose Symbolic Instruction Language. It’s all these early machines ran.
And they ran it slowly. BASIC is an interpreted language, translating each line of BASIC into machine code as it is run. This is completely different to compiled languages which do the translation all in one go. However on an 8 bit machine with only 64K of address space, this was all they could manage for the most part. If programmers wanted more out of the machine they needed to write in assembly language.
The problem with writing assembly language is that it needs compiling all in one go, which means the compiled code needs storing somewhere. And on a machine with only 64K of address space, with up to 32K of that being consumed by the system ROMs, there’s nowhere to put the compiled code. Even worse, most of these machines initially used tape to store data. Early assembly programmers were reduced to hand assembling code on paper before then writing a short BASIC loader program to manually insert the machine code into RAM.
To help reduce the memory requirement of the machine’s ROM code, Sinclair used a curious and unique method of keyword entry in their version of BASIC. Instead of typing out characters as normal, each key on the keyboard was assigned multiple different words. When in keyword entry mode, pressing a letter would automatically type out an entire BASIC keyword. This wasn’t a time saving feature, it was a memory saving feature. Each BASIC keyword on the Spectrum takes up one byte because each keyword is assigned a character code from the Spectrum’s character set, exactly the same way regular letters and numbers are.
This means that the machine only has to store codes that represent key words, effectively parsing and tokenising the BASIC instructions as they are being typed in by the user. The user literally cannot type in BASIC that won’t parse unless they get hideously confused by the keyboard layout and its numerous shift key states. It was not a pleasant way to write code.
By contrast the BBC Micro had a powerful BASIC interpreter, ran its own operating system and even had a built in assembler running in the BASIC interpreter. You could mix BASIC and assembly code together and the machine would just compile the assembler and run it amongst the BASIC. The BBC also implemented “sideways ROMs” using a form of bank switching so more programs could be accessed without needing to load off tape or disk. This gave the BBC Micro much more functionality compared to the cheaper and simpler Spectrum.
It’s quite interesting seeing the different tradeoffs and design choices two hardware manufacturers came up with. On one hand Sinclair were trying to make a cheap computer, and on the other hand Acorn were building a computer worthy of being used in schools across the country.