Acorn Electron: emulator, BBC BASIC, assembler and debugger
An Acorn Electron in your browser — the Electron ULA with MODEs 0–6, its palette registers and the RAM contention that slows the CPU in MODEs 0–3, the single sound channel, the keyboard matrix and UEF tapes through the ULA's cassette interface — with your own Acorn ROMs or an open stand-in OS. Type BBC BASIC, write 6502 assembly and debug it with breakpoints beside the code.
Added
How to use it
The Electron (1983) was Acorn’s cheaper BBC Micro: the same 6502 and BBC BASIC, with almost all of the BBC’s chips folded into one ULA. That ULA makes the picture, the sound and the cassette signal, and shares the RAM with the CPU — which is why the Electron runs slower in the big screen modes. This page builds on the BBC Micro emulator: the same 6502 core, UEF and tape code, assembler and debugger, with the Electron’s own hardware around them. Press Power on and click the screen to give it the keyboard.
ROMs
The Electron needs Acorn’s operating system (OS 1.00) and BBC BASIC II (the same BASIC ROM as the BBC Micro). They are still copyright: no rights holder has been found who allows them to be shared, and the Acorn community treats them like the BBC’s ROMs — see the RISC OS Open forum thread on the copyright status of Acorn ROMs. So this page does not include them. There is no open replacement for the Electron OS, and no open 6502 BBC BASIC (the open BBC BASICs — Richard Russell’s, Brandy — are for other processors).
Load ROM files… on the Machine tab takes the images you have: the 16 KB OS and BASIC ROMs, or
MAME’s 32 KB os_basic.ic2 holding both. They are recognised by CRC-32 (OS 1.00 bf63fb1f, BASIC
II 79434781, the pair b997f9cb) or by their contents, and kept in IndexedDB in this browser
only. A BBC Micro MOS is turned away: the Electron’s OS is different.
Without ROMs the machine runs Tiny OS for the Electron, an open stand-in written for this site
(its source is in acorn-electron-data.js, MIT licence): MODE 6 text drawn in the bitmap with a
public font, OSWRCH, OSRDCH from the keyboard matrix, OSWORD 0 (read a line) and 1 (read TIME,
kept by the RTC interrupt), OSBYTE &81 (INKEY) and &86, the vectors at &0200 (so IRQ1V and RDCHV
can be hooked as on the real OS) and BRK error messages. Machine code from the Assembly tab runs
on it; BASIC does not.
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 OS keyboard buffer a line at a time, exactly as if typed;
Ctrl+V on the screen (or Paste) types the clipboard. Examples: TAB in MODE 6, sixteen colours in
MODE 2, the inline assembler, SOUND and ENVELOPE, MODE 1 line art — and BASIC’s speed timed in
every MODE, which shows the contention: the same loop takes longer in MODEs 0–3. List it
detokenises the program between PAGE and TOP.
Assembly
The Assembly tab uses the site’s 6502 assembler (&FF or $FF for hex, labels in the first
column, .byte .word .text). 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. The examples program the hardware directly:
-
hello world with OSWRCH;
-
MODE 2 by hand — the mode bits in &FE07, the screen start in &FE02/&FE03 and all eight palette registers — with sixteen colour bars;
-
a raster split from IRQ1V: the RTC interrupt (scan line 100) turns the background red, the display-end interrupt blue again;
-
a scale on the ULA’s sound counter;
-
reading keys with OSRDCH;
-
the cost of video: the same RAM loop timed with OSWORD 1 in MODE 0 and MODE 6.
Build .UEF tape makes a tape for other emulators or a real Electron (through a tape interface).
Debugging
As on the BBC page: click a line number beside the code to set a breakpoint, F5 continue, F6 pause, F11 step, F10 step over, Shift+F11 step out, Ctrl+F10 run to the cursor. The Debugger tab names the OS entry points, the vectors and every ULA register in the disassembly, and has views of the ULA (interrupt status and enable bits, the mode, screen start, the beam, the ROM page, the palette registers and the colours they make), Sound and tape and an OS calls log.
Tapes and snapshots
Drop a .UEF tape (gzipped or not) on the screen: with Start what I load on, the page types
CHAIN "" or RUN. The ULA receives the tape itself — each byte raises "receive full", a
steady carrier "high tone" — and the OS reads it from &FE04. *Fast tape plays it about eight
times faster than 1200 baud; turn it off for real speed. SAVE and SAVE are recorded from the
ULA’s transmitter, and *Save recording downloads them as a UEF. Every file on a tape also has
Load & run, which needs no OS. Save state / Load state keep the machine as a .gwelk
snapshot (not the ROMs).
Keys
The Electron starts in CAPS LOCK: letters type as capitals, Shift+letter as lower case. Esc is ESCAPE, Backspace DELETE, End COPY, the arrows are the cursor keys, Tab is FUNC, Ctrl is CTRL. BREAK is a button (the Pause key works too); Ctrl+BREAK resets fully. On a phone, Keyboard shows an Electron keyboard.
Presenting
Full screen fills the screen with the Electron display; ⛶ Present (or F) shows only the screen for a talk. Keys keep working; Esc closes.
How it works
The 6502 is the BBC Micro page’s: instruction by instruction with exact cycle counts, NMOS decimal mode and the stable undocumented opcodes (it passes Klaus Dormann’s functional test). The Electron’s timing is in the bus: ROM runs at 2 MHz; every RAM access runs at 1 MHz (the RAM is four bits wide), plus a cycle to synchronise half the time; and in MODEs 0–3 the CPU is stopped while the ULA fetches its 80 bytes of each displayed line. The ULA draws a scan line at a time — 312 lines of 64 µs, 256 displayed (250 in MODEs 3 and 6) — from its own address counter, so palette and mode changes between lines show. The palette is decoded from the eight write-only registers exactly as they are wired (four logical colours per pair, a 0 bit lights a gun). The keyboard is the 14 × 4 matrix the OS reads through ROM pages 8 and 9; sound is the square wave from the counter in &FE06 (1 MHz / 32 / (S + 1)), mixed at 44.1 kHz.
Limits
-
No Acorn ROMs are included; without yours there is no BASIC.
-
No Plus 1, Plus 3, sideways ROMs or other expansions.
-
Interrupt timing is to the scan line; mid-line effects appear on the next line.
-
Tape: UEF data, carrier and gaps; no CSW, no tape sound.
Linking to an example
Share link copies the tab and the code or listing. Links can be written by hand:
| Parameter | Meaning | Example |
|---|---|---|
|
The tab: |
|
|
An Assembly example ( |
|
|
Assembly source for the editor |
|
|
A BASIC listing for the BASIC box |
|
|
Open full screen; run the code or listing straight away |
|
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.