Oliver VieBrooks

6basic

Commodore 64 BASIC 2.0 cross-compiler. Write BASIC in a text editor with labels, macros and named PETSCII codes, and get a normal .prg. Also lists and detokenizes existing programs, and has a turbo mode that replaces GOTO and GOSUB line searches with direct pointers.

Linux x646basic-2026.11.06-linux-x64.tar.gz28 MB
Windows x646basic-2026.11.06-win-x64.zip28 MB

Built 2026-11-06 from 6ea7bcf. Self-contained: no .NET install needed. SHA256SUMS

Unpack and put 6basic on your PATH. The Windows binary is unsigned, so SmartScreen may warn. {asm} blocks also need 6asm on your PATH.

Full reference: every option and source enhancement, and what isn't implemented yet.

Example

Source (bars.bas):

' bars.bas: labels instead of line numbers, macros for the colours
{#BORDER|53280}
{#PAPER|53281}

10 POKE {#BORDER},0:POKE {#PAPER},0
20 PRINT "{clear}{white}6basic sample{down:1}"
30 FOR I=1 TO 6:GOSUB {:BAR}:NEXT I
40 PRINT "{down}{yellow}tokenized from plain text."
50 PRINT "{light blue}labels resolve at compile time."
60 END

{:BAR}
100 RESTORE:FOR J=1 TO I:READ C$:NEXT J
110 PRINT C$;"{reverse on}                              {reverse off}"
120 RETURN
130 DATA "{red}","{orange}","{yellow}","{green}","{cyan}","{purple}"
$ 6basic bars.bas
Wrote bars.prg
$ 6basic listbasic bars.prg
10 POKE 53280,0:POKE 53281,0
20 PRINT "{clear}{white}6basic sample{down}"
30 FOR I=1 TO 6:GOSUB 100:NEXT I
40 PRINT "{down}{yellow}tokenized from plain text."
50 PRINT "{light blue}labels resolve at compile time."
60 END
100 RESTORE:FOR J=1 TO I:READ C$:NEXT J
110 PRINT C$;"{reverse on}                              {reverse off}"
120 RETURN
130 DATA "{red}","{orange}","{yellow}","{green}","{cyan}","{purple}"
$ 6basic bas2prg -f -turbo-data bars.bas bars-turbo.prg
Wrote bars-turbo.prg
$ wc -c bars*.prg
727 bars-turbo.prg
266 bars.prg
993 total
bars.prg in VICE. Text inside quotes is case-inverted on the way in, so write lower case to see upper case on the default charset.
bars.prg in VICE. Text inside quotes is case-inverted on the way in, so write lower case to see upper case on the default charset.

Commands

6basic game.bas source to game.prg
6basic bas2prg game.bas out.prg the same, explicit
6basic prg2bas game.prg game.bas detokenize to text
6basic listbasic game.prg list to the terminal
6basic dumpbasic game.prg hex dump
6basic game.bas -prg:build/game -hex several outputs in one run

Source language

{:LOOP} a label; GOTO {:LOOP} resolves to a line number at compile time
{#BORDER\|53280} replacement macro, used as {#BORDER}
{clear} {red} {f1} {down:5} named PETSCII codes, with repeat
{$0B} any byte
' comment stripped before tokenizing
{ifdef:NAME} {usedef:NAME} conditional compilation, with -def: on the command line
{asm} ... inline assembly through 6asm

Errors give the file and line, and nothing is written when compilation fails:

$ printf '10 GOTO {:NOPE}\n' > bad.bas
$ 6basic bad.bas
error: [bad.bas (1)] Undefined label {:NOPE} in: GOTO {:NOPE}
==== 1 Errors; 0 Warnings ====
Compilation failed (bad.bas): no output written.

Labels can cross files: -labels:lib.lbl exports them and -uselabels:lib.lbl imports them.

Turbo mode

GOTO, GOSUB and THEN targets are compiled to 3-byte pointers instead of ASCII line numbers, so the interpreter does not search for the line. It needs a 122-byte patch at $C000.

-turbo pointer BASIC only; you install the patch
-turbo-data patch included as a self-installing DATA preamble
-turbo-split program plus a separate .patch.prg

Turbo programs are not editable on a stock C64. listbasic recognises them and shows line numbers.