Chris Collins

Tools · retro

TRS-80 emulator and Z80 IDE

A TRS-80 Model I or Model III in your browser — the 64 × 16 screen with its 2 × 3 block graphics, the memory-mapped keyboard, the clock interrupt, cassette sound, .CAS tapes and .CMD programs — booting GW-80, an open monitor ROM written for this page (or your own Level II ROM for BASIC), with a Z80 assembler, examples and a debugger.

Added

How to use it

Press Power on, or just Assemble & run in the Code & debug tab — the TRS-80 starts by itself. It boots GW-80, a small monitor I wrote for this page, because Tandy’s BASIC ROMs are still copyrighted (more under ROMs below). Click the screen to give it the keyboard, type ? and Enter for the monitor’s commands.

How to use it

  • Code & debug — pick an example (hello world through $0033, a bouncing ball in block graphics, a random maze, the keyboard, sound through the cassette port, the clock interrupt) and press Assemble & run (Ctrl/⌘+Enter). Programs go at ORG $7000 or anywhere in RAM from $4000. With GW-80 your code is called the way the monitor’s G command calls it, and RET comes back to the > prompt. With your own ROM the page starts BASIC, answers MEMORY SIZE? (and the Model III’s Cass?) with Enter, waits for READY, then calls your code and puts every register back when it returns.

  • Breakpoints and stepping — click a line number to set a breakpoint, right-click it to run to it. Beside the editor are the screen, Run/Continue (F5), Pause (F6), Step (F11), Step over (F10), Step out (Shift+F11), Run to cursor (Ctrl+F10), the registers (type to change one), the flags (click to flip), the code at PC, the stack and watches. The Debugger tab has a longer disassembly with breakpoints and memory you can edit.

  • Files — drop a .CAS tape or a .CMD program on the screen, or use Open file…. A SYSTEM tape is loaded with GW-80’s L and started with G (the page types them); with Level II the page types SYSTEM, the file’s name and /, or CLOAD and RUN for a BASIC tape. A .CMD file’s blocks go straight into memory and it starts at its transfer address. .BAS / .TXT listings are typed into BASIC.

  • Type text — paste a BASIC listing or monitor commands and the page presses the keys.

  • Build .CMD and Build .CAS save your assembled program for other emulators or a real machine (a .CAS turns into audio with the usual tools).

The assembler is this site’s Z80 assembler: labels, local .labels, ORG, EQU, DB, DW, DS, expressions and every undocumented instruction. The ROM entry points GW-80 shares with Level II are predefined: DSPCHR ($0033, print A), KBSCAN ($002B), KBWAIT ($0049), GETLIN ($0040), DELAY ($0060), CLS ($01C9), VIDEO ($3C00), KEYBOARD ($3800), CURSOR ($4020) and TICKS ($4040).

The machine

  • Model I — the Z80 at 1.774 MHz (10.6445 MHz ÷ 6), 4–12 KB of ROM, the keyboard at $3800, 1 KB of video memory at $3C00, RAM from $4000 (16, 32 or 48 K). With the expansion interface ticked, a clock interrupt every 25 ms (40 Hz) that reading $37E0 clears. Port $FF drives the cassette (bits 0–1 out, bit 2 the motor, bit 7 in) and the 32-column wide mode (bit 3). An unmodified Model I has no bit 6 in video memory; tick the lower-case kit off to see what that does to lower case.

  • Model III — 2.028 MHz, 14 KB of ROM, the clock interrupt every second video field (30 times a second; 25 on 50 Hz machines), masked on port $E0 and cleared by reading $EC, and the wide mode on port $EC.

  • Screen — 64 × 16 characters of 6 × 12 dots; codes $80–$BF are 2 × 3 blocks (bit 0 top left … bit 5 bottom right), the 128 × 48 grid of Level II’s SET and POINT. White, green or amber phosphor (Video tab). The character shapes are my own, not Tandy’s.

  • Keyboard — eight rows read at $3801, $3802, $3804 … $3880; a pressed key is a 1. The page types what you type: your " key presses Shift-2, as on the TRS-80.

  • Sound — there’s no sound chip: programs flip the two cassette output bits, and that comes out of your speakers.

  • Tape — .CAS files hold the bytes the ROM reads (a leader, the $A5 sync byte, then the file). Loading is instant: the page answers the ROM’s tape routines ($0296 find the sync byte, $0235 read a byte, $0287 and $0264 write) from the file. With your own ROM you can turn that off in the Tape tab and the ROM reads 500-baud pulses from the cassette port in real time. What a program writes to tape can be downloaded as saved.cas.

GW-80 and the ROMs

GW-80 (MIT licence, source in trs80-core.js, assembled when the page loads) is a monitor, not BASIC. Its commands: D [addr] dump, M addr change memory, G [addr] call, F start end byte fill, L load a SYSTEM tape, S start end entry name save one, C clear, ? help. It keeps the Level II ROM’s well-known entry points, so the examples and many small machine-code programs run on it; programs that call Level II’s BASIC internals or TRSDOS won’t.

Tandy’s Level I and Level II ROMs (Level II is also Microsoft’s) and the Model III ROM have never been released for free distribution, so they aren’t here. Level I BASIC grew out of Li-Chen Wang’s public-domain Palo Alto Tiny BASIC, but the ROM is Tandy’s work. If you own a TRS-80, drop its ROM on the ROM tab — 4 KB (Level I), 12 KB (Level II, one file) or 14 KB (Model III). It stays in this browser and is never uploaded. The BASIC examples (SET and RESET, primes) need it.

Keys

Letters, digits and punctuation type the character you press. Enter is ENTER, Esc is BREAK, Backspace and ← are the left arrow (Level II’s backspace), → and Tab the right arrow, ↑ ↓ the arrows, Home and Delete CLEAR, Shift on its own SHIFT. The on-screen keyboard is for phones. Works in current Chrome, Edge, Firefox and Safari; sound starts after you click the page.

Limits

  • No disk drives: no TRSDOS, no .DSK images. No printer, no RS-232.

  • The video is drawn once a frame (no Model I "snow" from video memory access).

  • Model III extras: the alternate character set and 1500-baud cassette in real time aren’t emulated (1500-baud tapes load through the fast-load path).

  • GW-80 isn’t Level II: BASIC programs and most commercial tapes need your own ROM.

Privacy

Everything runs in your browser. ROM files you load are kept in this browser’s IndexedDB and never leave it; the page loads no third-party scripts.

Linking to an example

Share link copies a URL with the example (or your source), the tab and the model — never tapes or ROMs.

Parameter Values

example

hello, blocks, maze, keys, sound, clock

mode

the tab: asm, debug, video, tape, paste, rom, software, keys, refs

model

1 or 3

run

1 assembles and runs the program when the page opens

Other Z80 machines here: the ZX Spectrum, the SAM Coupé, the MSX and the Amstrad CPC.

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