BASIC-to-Assembly Code Translator, Line Number Stripper & .PRG Binary Tokenizer

Convert Commodore BASIC V2, Sinclair BASIC & Locomotive/BBC BASIC into label-based code, MOS 6502/6510 or Z80 assembly templates, POKE/PEEK opcodes, and downloadable .PRG files

BASIC-to-Assembly Code Translator, Line Number Stripper & .PRG Binary Tokenizer

Transform legacy 8-bit BASIC programs from Commodore BASIC V2 (C64 / VIC-20), Sinclair BASIC (ZX Spectrum), and Locomotive / BBC BASIC into clean label-based source code, commented MOS 6502/6510 or Zilog Z80 assembly templates, hardware POKE/PEEK opcode tables, and downloadable Commodore .PRG binaries ready to boot in our Multi-System Retro Emulator Hub →

Target Architecture MOS 6510 / 6502 (C64 $0801)
Parsed BASIC Lines 12 Lines · 18 Statements
Branch Labels Generated 3 Labels (GOTO / GOSUB)
POKE / PEEK Opcodes 7 Hardware Register Hits
Tokenized .PRG Size 184 Bytes ($0801–$08B6)
1. Raw 8-Bit BASIC Source Input
2. Translated Output (Assembly / Stripped Labels / .PRG Hex)
Real-time AST & hardware register translation active Ready
3. Hardware POKE / PEEK & Branch Label Inspector (Cross-Linked to Memory Mapper) Open Visual Memory Mapper →

Every POKE, PEEK, GOTO, GOSUB, and hardware I/O statement in your BASIC program is decoded below into its exact 16-bit hexadecimal address, hardware chip register, and assembly opcode sequence. Click any address to inspect its memory bank in the Cross-Architecture Visual Memory Mapper:

BASIC Line Source Statement Target Address / Label Hardware Chip / Register Function Generated Assembly Opcodes

How 8-Bit BASIC-to-Assembly Translation & .PRG Tokenization Work

  • Line Number Stripping & Control-Flow Graph Relabeling: Classic 8-bit interpreters (Commodore BASIC V2, Sinclair BASIC, and Locomotive BASIC) require line numbers on every line, making refactoring slow and obscuring true branch entry points. Our parser scans all GOTO, GOSUB, THEN <line>, ON..GOTO/GOSUB, and RESTORE targets first, strips unreferenced line numbers, and emits clean symbolic labels (e.g. line_100:) mapped to JMP line_100 / JSR line_500 on MOS 6502/6510 or JP line_100 / CALL line_500 on Zilog Z80A.
  • Hardware POKE & PEEK to Native Opcode Translation: On 8-bit home computers, graphics, sprites, and sound are driven by memory-mapped registers. Statements like POKE 53280, 0 and PEEK(53281) are automatically matched against our hardware register database (VIC-II $D000–$D02E, SID 6581/8580 $D400–$D41C, 2114 Color SRAM $D800, 6526 CIA $DC00/$DD00, VIC 6560 $9000–$900F, and ZX Spectrum ULA $4000/$5800) and converted into immediate/absolute load-store pairs (LDA #$00 : STA $D020 / LDA $D021) with deep-links to the Visual Memory Mapper & Address Decoder.
  • Authentic Commodore Binary .PRG Serialization: A native Commodore .PRG file begins with a 2-byte Little-Endian load address ($01 $08 for $0801 on the C64, or $01 $10 for $1001 on an unexpanded VIC-20). Each BASIC line is serialized as a 2-byte pointer to the next line's RAM address, a 2-byte unsigned 16-bit line number, single-byte keyword tokens ($80 END through $CB GO, while leaving characters inside quotes and after REM/DATA untouched as PETSCII), and a $00 line terminator, followed by two final $00 $00 null bytes marking the end of the program.

Comments (0)

No comments yet. Be the first to share your thoughts on this tool!

Leave a Comment

Theme Palette

Default Dark
High-contrast dark
Amber Terminal
Monochrome amber
Matrix CRT
Phosphor green
Workbench Light
Clean light mode

Audio & Display

Relay Click Sounds Web Audio API — soft mechanical clicks
CRT Scanline & Flicker Pure CSS overlay effect

System Info

Customization Panel Theme preference, audio FX, and CRT overlay settings are saved to your browser's localStorage and persist between visits. No cookies or server-side storage is used.
Keyboard Shortcuts Press Esc to close this panel. Use the header moon/sun icon to cycle themes.