Chris Collins

Tools · retro

BBC Micro: emulator, BBC BASIC, assembler and debugger

A BBC Micro Model B in your browser — 6845 CRTC and video ULA (MODEs 0–7 with MODE 7 teletext), both 6522 VIAs, the SN76489, UEF tapes and SSD/DSD discs through an emulated 8271 — with your own Acorn ROMs or an open stand-in OS. Type BBC BASIC (inline [ ] assembler included), write 6502 assembly, and debug with breakpoints beside the code, stepping, OS call labels and chip views.

Added

Works with

How to use it

Press Power on and the BBC starts. The page has five tabs around one emulated Model B: Machine (ROMs, tapes, discs, snapshots, the keyboard), BASIC, Assembly, Debugger and References. Click the screen to give it the keyboard.

ROMs

The BBC Micro needs Acorn’s operating system (MOS 1.20), and BBC BASIC II to do anything in BASIC; Acorn DFS 1.20 adds the disc filing system. These ROMs are still copyright: other emulators that ship them do so without a licence — jsbeeb’s ROM folder says "The ROMs here are NOT GPL. They are copyrighted still, but I think it’s fair use provided you actually own these ROMs" (jsbeeb roms/README), and the Acorn community has found no rights holder who grants permission (RISC OS Open forum: copyright status of Acorn ROMs). So this page does not include them.

Load ROM files… on the Machine tab takes the ROM images you have. Each one is recognised by its checksum (MOS 1.20 3c14fc70, BASIC II 79434781, DFS 1.20 8ccd2157, CRC-32) or by its sideways-ROM header, put in the right socket (the OS at &C000, languages from slot 15 down, service ROMs such as the DFS from slot 14 down), and kept in IndexedDB in this browser only.

Without ROMs the machine runs Tiny OS, this site’s open stand-in for the MOS: MODE 7 text output (OSWRCH, OSASCI, OSNEWL, VDU 31), OSRDCH from the keyboard, OSWORD 0 (read a line), OSBYTE &81 (INKEY) and BRK error messages. Machine code from the Assembly tab runs on it; BASIC does not. Its source is in bbc-micro-data.js.

BASIC

Type at the > prompt, or use the BASIC tab: pick an example or paste a listing and press NEW, type & RUN. The text goes into the MOS keyboard buffer a line at a time, exactly as if typed. Examples: colours and double height in MODE 7, the inline assembler ([OPT pass% …] in a two-pass FOR loop, then CALL), BASIC against machine code timed with TIME, MODE 1 line art, SOUND and ENVELOPE, and a recursive tree with PROC. List it detokenises the program between PAGE and TOP; it can be saved as text or as the tokenised bytes.

Assembly

The Assembly tab uses the site’s 6502 assembler: labels in the first column, NAME = value, .byte .word .text, < and > for low and high bytes; hex as &FF (BBC style) or $FF. Assemble & run (Ctrl+Enter) resets the machine, waits for the > prompt, puts the code in memory and types CALL &2000 — or, under Tiny OS, jumps there; RTS comes back. Examples: hello world with OSWRCH, MODE 7 teletext codes, MODE 2 set up by programming the 6845 and video ULA directly, reading keys with OSRDCH, a scale played on the SN76489 through the System VIA, and rainbow raster bars from a vsync interrupt and User VIA timer 1 (this one needs the MOS). Build .UEF tape and Build .SSD disc (a bootable !BOOT) make files for other emulators or a real BBC; Load as tape and Boot as disc use them here.

Debugging

The Assembly tab is a split view: the editor, and beside it (below on a phone) the screen with the registers, flags, stack, code around PC and watches.

  • Click a line number beside the code to set a breakpoint; right-click it to run to that line; F9 toggles the cursor line. Breakpoints follow their lines through edits.

  • F5 continue, F6 pause, F11 step, F10 step over a JSR, Shift+F11 step out, Ctrl+F10 run to the cursor line. On the BBC screen F1–F10 are the red function keys, so use the buttons or click outside the screen.

  • When the program stops, the line is marked, and the status says where — your line, the OS ROM, or a sideways ROM — with the CRTC row and scan line.

The Debugger tab works on anything that runs (BASIC, the MOS, a game). The disassembly names the OS entry points (OSWRCH &FFEE, OSBYTE &FFF4, OSWORD &FFF1, OSRDCH &FFE0 …), the vectors at &0200 (WRCHV, IRQ1V …) and every SHEILA register (CRTC_ADDR, SYSVIA_IFR, ULA_PALETTE …). Views: CRTC and ULA (all 18 registers decoded, screen start, beam position, the ULA control register and the 16-entry palette), VIAs (ports, both timers, IFR/IER, the addressable latch, keys held), Sound (each SN76489 channel’s period, frequency and attenuation), Tape and disc (the ACIA, serial ULA and 8271 state) and OS calls — a log of OSBYTE, OSWORD and OSWRCH calls with what each does.

Tapes, discs and snapshots

Drop files on the screen or the Tapes and discs box:

  • .UEF (gzipped or not) — goes in the cassette; with Start what I load on, the page types TAPE and CHAIN "" (or *RUN for machine code). *Fast tape loads about eight times faster than 1200 baud through the MOS’s own tape code; turn it off for real speed. SAVE to tape is recorded, and Save recording downloads it as a UEF.

  • .SSD / .DSD — goes in drive 0. The DFS ROM drives an emulated 8271 controller, so CAT, CHAIN, *RUN, SAVE and *SAVE work (writes are kept; *Download saves the changed image). A disc with a boot option starts with SHIFT+BREAK. Every file in the catalogue also has Load & run, which puts it straight into memory — no DFS needed.

  • Save state / Load state store the whole machine as a .gwbbc snapshot (not the ROMs).

The Software panel lists freely distributable programs this site can share, and opens files from a URL or an archive.org item.

Keys

The BBC starts with CAPS LOCK on: letters type as capitals, Shift+letter as lower case. Esc is ESCAPE, Backspace DELETE, End COPY, the arrows are the cursor-editing keys, F1–F9 are f1–f9 and F10 is f0. BREAK is a button (the Pause key works too); Ctrl+BREAK resets fully. On a phone, Keyboard shows a BBC keyboard.

Presenting

Full screen fills the screen with the BBC display; ⛶ Present (or F) shows only the screen for a talk. Keys keep working; Esc closes.

How it works

The 6502 is emulated instruction by instruction with exact cycle counts, NMOS decimal mode and the stable undocumented opcodes; it passes Klaus Dormann’s 6502 functional test. Accesses to the 1 MHz devices stretch the cycle. The 6845 is stepped a scan line at a time and the video ULA decodes each line from memory (the ULA’s 4-bit palette lookup, the screen wrap-around set by the addressable latch, the hardware cursor), so palette changes between lines (raster bars) show. MODE 7 is drawn by an SAA5050 model — control codes, set-at and set-after, double height, mosaics contiguous and separated, hold graphics, flashing — using Bedstead's glyphs (CC0) with the chip’s character rounding. The VIAs run their timers at 1 MHz with the 6522’s latching and interrupt flags; the keyboard is the real 10 × 8 matrix with autoscan and CA2 interrupts. Sound is the SN76489’s three square waves and noise, replayed from the register writes and mixed at 44.1 kHz.

Limits

  • No Acorn ROMs are included; without yours there is no BASIC or DFS.

  • Video is per scan line, not per character: mid-line register changes appear on the next line.

  • No Tube, Econet, speech, RS423, printer or user-port devices; the ADC reads a centred joystick.

  • The 8271 is modelled at command level (non-DMA transfers, no copy-protection quirks); disc images are standard 80-track SSD/DSD.

  • Tape: UEF chunks for data, carrier and gaps; no CSW, and no tape sound.

  • Model B only (no B+, Master or Electron).

Linking to an example

Share link copies the tab and the code or listing. Links can be written by hand:

Parameter Meaning Example

mode

The tab: machine, basic, asm, debug, refs

mode=asm

example

An Assembly example (hello, teletext, mode2, keys, sound, irq) or, with mode=basic, a BASIC one (hello, inline-asm, asm-speed, graphics, sound, tree)

example=inline-asm

src

Assembly source for the editor

src=…

basic

A BASIC listing for the BASIC box

basic=10 PRINT "HI"

present, autostart

Open full screen; run the code or listing straight away

autostart=1

Runs entirely in your browser; nothing you type leaves this page.