I moved from Sinclair/Amstrad CPC games development onto the Gameboy. Initially the lack of EXX and IX/IY proved to be a bit of a pain. It's also missing the LDI(R)/LDD(R) opcodes. However, I dimly remember using its LD A, (FF00+...) instructions to access a block of RAM at the top of the memory map above the I/O registers to store variables, in much the same way that I'd use zero page on a 6502. So not quite as restrictive as it looks.
This is an ongoing project I started during Covid lockdown, building a fully functional and MSX compliant computer on a breadboard. It's a good introduction to CPUs, logic, and digital electronics. This is part 1 of a series that I update periodically.
The BBC Basic for Z80 kernel was written by R.T.Russell around the same time as the original 6502 version that ran on the BBC Micro. The CP/M version was open-sourced in 2019, and I used that core BASIC interpreter in a homebrew computer, with the CP/M code stripped out.
A few weeks ago after a chance conversation on social media, I decided to port it again to the ZX Spectrum Next (a modern reincarnation of the original ZX Spectrum). Whilst it's another Z80-based system, the challenge would be to add in all missing features from the core language such as an editor, graphics, sound, file IO, and so on.
The link above is to my blog, which I'll be updating on a regular(ish) basis with insights into the code. I'll also be updating the Git project page (link to the project in the post) with source code and executable 'nex' files that can be run on a Spectrum Next (or clone), on a MiSTer FPGA running the ZX Next core, or in a Next emulator such as ZEsarUX or CSPect.
Why am I doing this? I think BBC Basic is the best-in-class of its peers. It's performant, and has many modern language features. It's also a pretty cool way to get to grips with the Next hardware. I'm really enjoying working on this. The Spectrum Next is the 8-bit micro I wish I'd had back in the 80s, and the project is interesting, and something I can continuously improve upon.
Indeed! R.T.Russel's Z80 version also includes a built-in Z80 assembler that works in exactly the same way. Being able to inline assembler with BASIC was a stroke of genius, and many developers of the day relied upon it to assemble their code. I've extended the Next version to include the Next-specific Z80N opcodes such as NEXTREG and PIXELAD.
So you are saying some part of the (language, compiler, runtime, generated code, etc.) is... what, exactly?
Perhaps one or more of: {Memory-,CPU-,Power-}efficient? Fast? Compact? Reliable/non-buggy? Easy to use? Expressive? Easy to understand, maintain or port? Standards-compliant? Or maybe that it contains a useful and complete API for a certain application domain (e.g. games/sound/animation on the Spectrum Next?) Or maybe it has a nice IDE or workflow? All/some of the above?
And ... compared to what? Other BASIC compilers for ZX or for CP/M? Other CP/M languages/IDEs like Turbo Pascal (which sounds like it was a pretty great environment according to folks on HN at least?)
Performant as a measure of speed against rival BASIC interpreters.
BBC Basic is recognised as being one of the fastest floating point BASIC interpreters written for 8-bit CPUs. This was partly down to how the language was coded (in 6502 originally), and certain aspects of the BBC Micro's architecture. Although the BBC Micro's CPU was only running at 2Mhz, it had fast RAM chips with little to no contention, despite sharing memory with the video system.
These benchmarks give some indication of relative speeds to its contemporaries.
I've run those benchmarks on the Z80 version. It is faster than the native BASIC of the Spectrum (Sinclair BASIC) running at the same CPU speed (3.5Mhz).
BBC BASIC was noted at the time for being much faster than the BASICs on similar machines of the era. I believe this was a mix of the BASIC itself being simply better, the hardware being a bit faster, and tricks like inline asm being possible. There were even action games written in BBC BASIC.