BBC BASIC II and III

November 27, 2025 · View on GitHub

This is a fully annotated disassembly of BBC BASIC II and III.

Build with the Mad-Assembler.

Run BBC BASIC on Linux!

Or on an Atari XL/XE!

Currently, the following versions are supported:

ROMrefVersionLoadMD5
Systemsbasic2.romSBasic2.fixed22.00$A00074c803820eb39ff8b693ea3a90f05b33
Systemsbasic310.romSBasic310.fixed3.10$A000477d2c05b550ecb2730814ba1068b0d1
Atomatbasic2.romAtBasic2.fixed22.00$400007936440e266d780d4082f2844aa78e4
Atomatbasic310.romAtBasic310.fixed3.10$40005ca195f247cd1dabb311f2207220df2b
BBCbasic2.romBasic22.00$80002cc67be4624df4dc66617742571a8e3d
BBCbasic3.romBasic 33.00$8000361148f2ae1cb2c87885bcb463d9e74c
BBCbasic310hi.romHiBasic3103.10$B80068e79c8b6f46aa4f07a6dd687897229c
C64c64basic2.romC64Basic2.fixed2.00$B80089f5b82721cb351f22145ee0c07530c2

Notes:

  • The fixed reference ROMs contain the proper floating point value for 5.00000 in the FEXPCO table. See this commit at line 7481 for details.
  • The fixed2 reference ROMs contain previous fix, and a fix in the INSTR instruction that branched to the wrong memory location on error. See this commit for details.

When porting to a new system, keep in mind that BBC BASIC uses the 6502 BRK instruction for error handling. This can be problematic due to the 6502 NMI/BRK bug. If an NMI occurs at the same time as a BRK instruction, you can end up in the NMI handler instead of the IRQ handler. This can be detected by checking the B bit in the P register on the stack. Your NMI handler must do this, otherwise a simple program like this could crash:

10 ON ERROR E%=E%+1
20 PRINT E%;".";
30 E%=1/0

If that would mean your NMI handler becomes too slow to handle certain interrupts (like raster interrupts, or serial communication), you need to replace all BRK instructions with JSR fake_brk and implement fake_brk to properly setup FAULT and jump to the BREK handler routine.

Credits

Conversion to mads, improvements, lots of comments, and bug fixes by Ivo van Poorten, 2025
ARM Basic 65 source reconstruction and commentary, Copyright © 2018 J.G.Harston
BBC BASIC Copyright © 1982,1983 Acorn Computer and Sophie Wilson
The BBC Micro Compendium by Jeremy Ruston, © 1983
Thanks to Paul Fellows for releasing the original CmosBasic, DmosBasic, and Basic128 sources.