Chris Collins

Tools · retro

Commodore PET: emulator, BASIC, assembler and debugger

A Commodore PET in your browser — the 2001, 3032 and 4032 with the 40-column screen, or the 80-column CBM 8032; graphics or business keyboard, green, white or amber phosphor, the CB2 beeper, the 6520 PIAs and the 6522 VIA. It boots Microsoft's open-source BASIC 1.1 on a KERNAL written for this site, or your own ROMs; loads PRG, D64 disks and TAP tapes, and saves to them. Write 6502 assembly and debug it beside the code.

Added

How to use it

The PET 2001 (1977) was Commodore’s first computer: a 6502 at 1 MHz, a built-in green screen and cassette, and Microsoft BASIC in ROM. The 3000, 4000 and 8000 series followed with more memory, better BASICs and, on the 8032, 80 columns. Press Power on (or Assemble & run in the Assembly tab) and it boots to READY.. Click the screen to give it the keyboard.

Commodore’s ROMs are still under copyright, so this page doesn’t ship them. It runs Microsoft’s BASIC 1.1 for the 6502 instead — released under the MIT licence in 2025, and the very source the PET’s first BASIC came from, built here in its own PET configuration — on a KERNAL written for this site. If you own the ROM dumps, load them.

How to use it

  • Type BASIC on the screen: 10 PRINT CHR$(205.5+RND(1));:GOTO 10, RETURN, RUN. RUN/STOP (Esc) breaks; move the cursor onto any line, change it and press RETURN to enter it again. Type into the computer on the Run tab types a listing, BASIC examples… has a few (the maze, primes, the screen, a tune on CB2, saving to disk), and pasting onto the screen types too.

  • Model: the PET 2001 (8 KB, BASIC 1), 3032 (32 KB, BASIC 2), 4032 (32 KB, BASIC 4) and the CBM 8032 (80 × 25, business keyboard). With the open BASIC they differ in memory and screen; with your own ROMs, in everything. The 40-column models take the graphics keyboard (graphics on the shifted letters, a numeric keypad of its own, upper case at power-on) or the business keyboard (typewriter layout, ESC, TAB and REPEAT, starts in lower/upper case).

  • Programs, disk and tape: drop a .PRG, .D64 or .TAP on the screen. In BASIC, LOAD"$",8 and LIST show the disk’s directory, LOAD"NAME",8 loads, SAVE"NAME",8 saves (onto a blank disk if none is in), LOAD and SAVE"NAME" use the tape. The Disk drive and Datassette panel lists both with Run buttons and downloads them as .D64 / .TAP; they are kept in this browser.

  • Sound: the PET’s beeper is the VIA’s shift register sending a bit pattern out of CB2 — POKE 59467,16, POKE 59466,15 and POKE 59464, a pitch (the CB2 sound example in assembly and Sound on CB2 in BASIC).

  • On a phone: ⌨ Keys opens an on-screen PET keyboard (graphics or business layout); SHIFT stays down until the next key.

Keys: Esc is RUN/STOP, Tab RVS, Backspace DEL (Insert: INST), Home HOME (Shift: CLR), the arrows the cursor keys. Shift + a letter gives the graphics character (a capital in lower-case mode); POKE 59468,14 or PRINT CHR$(14) switches to lower case.

Assembly and debugging

The Assembly tab assembles 6502 code and runs it: the PET is reset, the page waits for READY., loads the code (from $1000 in the examples), keeps BASIC’s memory below it and types SYS; RTS returns to BASIC. The examples need no ROMs: hello world with CHROUT, the screen at $8000, CB2 sound, GETIN, and the two character sets. Breakpoints go beside the code (F9), with F5 / F6 / F10 / F11 / Shift+F11 / Ctrl+F10 to continue, pause, step over, step, step out and run to the cursor; registers, stack, disassembly with KERNAL and chip names, memory and watches sit beside the editor. The Debugger tab shows the PIAs (the keyboard row PIA 1 selects, the retrace interrupt), the VIA (timers, shift register, the character-set line), the CRTC registers and the memory map with BASIC’s pointers.

Firmware

  • Open BASIC (the default): Microsoft BASIC 1.1 (source, MIT) in its Commodore configuration, built by this site’s script, with marked changes so it runs on the stub KERNAL. Its zero page is already the BASIC 2 layout, so PETs' programs that PEEK BASIC’s pointers find them. Bytes free: 7167 on the 2001, 31743 on the others — the real machines' numbers.

  • Monitor only: the stub KERNAL’s hex monitor (SYS 65280 from BASIC, X back).

  • My ROMs: load the chips you own — VICE’s basic1/basic2/basic4, edit… and kernal1/2/4 files, single chips named by address ($B000 … $F000) or Commodore part number (901465-01 …), or a dump of the top of memory — and the 2 KB character ROM (901447-10). Commodore’s chips are recognised by CRC-32 and named; each model keeps its own set in this browser.

The stub KERNAL is this site’s own code (MIT, source on the References tab): CHROUT, CHRIN, GETIN, PLOT and the rest at their usual addresses, a screen editor with 80-character logical lines on the 40-column PETs, the keyboard scan on the retrace interrupt into the real KERNAL’s buffer ($026F), and the monitor. LOAD, SAVE and VERIFY are done by the emulator for any BASIC — the open one or Commodore’s 1, 2 or 4 — by catching the statement and reading the disk image or tape directly, so the IEEE-488 bus and the drive’s own CPU aren’t emulated.

The screen font is drawn for this site (thin strokes, like the PET’s): letters from Dale Schumacher’s Clean 8×8 font, PETSCII graphics by hand. Open ROMs font switches to the MEGA65 Open ROMs set (LGPL), which looks more like a VIC-20 or C64.

Limits

  • Instruction-stepped CPU with documented cycle counts; the screen is drawn once a frame, so there are no CRTC tricks (the 8032’s CRTC registers are kept but not used for the picture).

  • Tape and disk at the BASIC/KERNAL level: no fast loaders or protected disks, no OPEN command channel, no printer. .TAP files must be in the KERNAL’s own format.

  • The open BASIC is BASIC 1.1: no BASIC 4 disk commands (DIRECTORY, DLOAD …), no OPEN or PRINT# files, and BASIC 1’s behaviour in places.

Linking to an example

Parameter Meaning Example

mode

Tab: run, asm, debug, refs

mode=asm

example

hello, screen, sound, keys, charset

example=sound

pet

Model: 2001, 3032, 4032, 8032

pet=8032

keyboard

graphics or business

keyboard=business

firmware

basic, monitor or roms

firmware=monitor

present=1, autostart=1

Open the screen full-window and run the program

autostart=1

For example: ?pet=8032&mode=asm&example=hello&autostart=1, ?mode=asm&example=sound. Share links never carry programs, disks or ROMs.

Browser support and privacy

It runs in any current browser; sound starts after the first click. The first time, the page fetches the open BASIC from this site (about 25 KB). Programs, disks, tapes and ROMs you open stay in your browser (IndexedDB) and are never sent anywhere.

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