6502 WASM Runner — 64 KiB flat RAM
Fast, cycle-agnostic NMOS 6502 execution. No devices, display, timers or memory-mapped I/O are emulated. The runner stops when the program counter reaches the escape address before opcode fetch, on an unsupported opcode, at an optional instruction limit, or when the JavaScript stop flag is observed between WASM chunks.
Compatible with the RetroAppleJS tab 1.2 paste/memory-capture format. Import addressed monitor lines directly into RAM, or export any RAM range as CALL-151 text with eight bytes per line.
The first row contains the editable latch values. The second row shows the current CPU state and is read-only. Latch values are preserved while the CPU runs, so the original setup remains available for reuse or modification.
Optional diagnostic logging compatible with the JavaScript emulator bootlog record format: 10 bytes per record containing pre-execution PC, opcode/operand, A, X, Y, P and SP. Logging uses single-instruction WASM calls and is therefore intentionally slower than a normal run.
await CPU6502.run(config, ramUint8Array) returns { ram, state, reason, instructions }. The input RAM must contain exactly 65,536 bytes. A fresh copy of final RAM is returned.
| config property | meaning |
|---|---|
pc,a,x,y,sp,p | initial register values; defaults: PC=0, A/X/Y=0, SP=$FD, P=$24 |
useResetVector | if true, PC comes from $FFFC/$FFFD and reset-state registers are used |
escapeAddress | default $FF69 |
escapeEnabled | default true |
instructionsPerChunk | default 1,000,000; may be 100,000,000 for infrequent polling |
maxInstructions | 0/omitted = unlimited |
shouldStop | optional callback checked between chunks; ends the run with reason stop |
shouldPause | optional callback checked between chunks; returns the current RAM/register state with reason pause |
onProgress | optional callback receiving the current CPU state and executed-instruction count at polling boundaries |
yieldBetweenChunks | default true; lets browser process UI events |
activityLog | default false; when true, captures a JavaScript-emulator-compatible pre-execution CPU activity log |
activityLogSize | maximum activity-log records; default 32,768 |
CPU6502.importMonitorText(text, ram) | imports RetroAppleJS/Apple II Monitor deposit lines into a copy of RAM |
CPU6502.exportMonitorText(ram, from, to) | exports an inclusive RAM range as CALL-151 plus eight-byte monitor lines |