ugBASIC
An open-source isomorphic BASIC cross-compiler by Marco Spedaletti that turns one source file into native 6502, 6809, 6309, Z80 and SM83 assembly for dozens of 8-bit home computers and consoles.
Created by Marco Spedaletti
ugBASIC is an open-source cross-compiler for a BASIC dialect aimed squarely at 8-bit
retrocomputers. Written in C by the Italian developer Marco Spedaletti and first published
in 2021, it takes a single .bas source file and emits native assembly - and from there a
ready-to-run .prg, .tap, .rom, .bin or disk image - for dozens of machines built
around CPUs including the MOS 6502/6510/8502, the Motorola 6809, the Hitachi 6309, the
Zilog Z80 and the Game Boy’s Sharp SM83. It is not an interpreter, not a runtime, and not a virtual machine:
the BASIC is gone by the time the program reaches the target, replaced by hand-tuned
assembly libraries selected per CPU and per chipset.
The name is an acronym. Per the project’s own README, the u stands for micro, “because it is a ‘minimal’ language, which is translated as linearly as possible into assembly without abstractions”, and the g stands for game, “because the language was designed to write video games, even advanced ones.”
History and origins
Spedaletti created the GitHub repository on 25 April 2021 and tagged the first public
release, v1.0-beta, on 31 July of that year. The early betas were narrow: MOS 6502 code
generation for Commodore hardware, a handful of graphics primitives, and the BUFFER and
IMAGE datatypes that arrived in v1.2-beta in August.
The project’s character changed with v1.3-beta in September 2021, which added a Motorola
6809 back end, support for the Motorola 6847 video chipset, and the Dragon 32 as a target.
From that point the compiler was structurally multi-CPU rather than a Commodore tool with
ports bolted on, and the release history reads as a steady march through 8-bit computing
history: the Olivetti Prodest PC 128 and Thomson MO5 in v1.4 (October 2021), MSX1 and
ColecoVision in January 2022, the SEGA SC-3000 and SG-1000 in February 2022, the Commodore
128 in May 2022, the Amstrad CPC in November 2022, the TRS-80 Color Computer in February
2023, the Game Boy in January 2025, and the Commodore 16 plus a set of Hitachi 6309 variants
in October 2025.
Development has been regular. Forty-eight tagged releases were published between July 2021 and May 2026, most of them only weeks or a couple of months apart - though the gap between v1.18 (October 2025) and v1.18.1 (May 2026) stretched to seven months. Each is accompanied by detailed release notes listing new keywords, new targets and per-chipset fixes.
Design philosophy: isomorphism
The word ugBASIC uses for its own approach is isomorphism, and the project defines it as “the attempt to match one part of one computer to the counterpart part of another computer in the ‘best way’.”
This is a deliberate rejection of the usual portability strategy. A conventional
cross-platform toolkit abstracts the hardware, presenting a lowest-common-denominator screen
or sound API and paying for the abstraction in code size and speed - a cost that is fatal on
a machine with 38 KB of usable RAM and a 1 MHz CPU. ugBASIC instead maps each language
construct onto whatever the target actually has. SPRITE becomes VIC-II hardware sprites on
a Commodore 64 and TMS9918 sprites on an MSX; on a machine with no sprite hardware the
instruction may behave differently or not exist at all. The result is that the same program
runs everywhere, but looks different depending on what the hardware can do - the project
is explicit that visual results will differ rather than being degraded to match the weakest
target.
Several consequences follow from this, and the project states them plainly:
- No stack use. Memory is allocated statically, because 8-bit processors generally lack efficient stack support. Calculations are performed on integers by default.
- No ROM dependency. Generated executables take over the hardware themselves rather than calling resident BASIC or KERNAL routines, so ROM can be swapped out for RAM where the machine permits it. Release v1.7.1 (December 2021) replaced KERNAL IRQ handling with the compiler’s own on the Commodore 64 for exactly this reason.
- Direct-to-assembly compilation. Source, graphics and audio resources are all compiled to assembly and optimized per CPU, with peephole optimizers for the 6502, 6809 and Z80.
Spedaletti also explains why BASIC in particular: besides being “the language of choice for almost all home computers of the time”, it is “a language that makes no distinctions between ‘syntax’ and ’libraries’, and is therefore ideal for isomorphism” - a comfortable host for a paradigm where the meaning of a keyword is allowed to depend on the machine underneath.
Key features
| Area | What ugBASIC provides |
|---|---|
| Graphics | BITMAP ENABLE, PLOT, LINE, BAR, DRAW, PAINT, palettes, double buffering, hardware and multiplexed sprites, tiles and tilemaps (with preliminary Tiled tilemap import since 1.14.2) |
| Images | LOAD IMAGE, LOAD IMAGES, LOAD SEQUENCE, LOAD ATLAS, PNG transparency, automatic conversion to the target’s native pixel format, optional MSC1 compression |
| Audio | PLAY, NOTE, INSTRUMENT, VOLUME, BELL, SHOOT, BOOM, MIDI import, and native SID file loading on the Commodore 64 and 128 targets, added in 1.17 |
| Multitasking | PARALLEL PROCEDURE, RUN PARALLEL, HALTED SPAWN, RESPAWN, built on protothreads; GAME LOOP blocks synchronize to the vertical blank |
| Storage | BEGIN STORAGE / ENDSTORAGE, DLOAD, DSAVE, and generation of ATR, DSK and D64 disk images |
| Memory | Banked resources, the Commodore 64 REU and geoRAM expansions, with automatic loading into memory banks - on the c64reu, pc128op, to8 and coco3 targets - since 1.16.4 |
| Escape hatches | Inline assembly modules, SYSCALL, SYS, PEEK/POKE, IN/OUT, and PROCEDURE ... ON <target> for per-machine code paths |
Sources are recognizably BASIC, but with modern structure - named procedures, constants,
SELECT CASE, OPTION EXPLICIT, includes, and a direct-assignment operator :=. A
multitasking example from the repository reads:
| |
And an animation example shows the resource-loading style, where an image atlas becomes a first-class value:
| |
Examples in the repository carry an @include comment listing the targets each one is known
to build for - an honest acknowledgement that isomorphism has limits and that not every
program makes sense on every machine.
Evolution
Three themes run through the release history.
Breadth of hardware. The target list grew from Commodore-only in mid-2021 to a collection spanning Amstrad, Atari, Commodore, Dragon, Game Boy, MSX, Olivetti, SEGA, Thomson, TRS-80 and ZX Spectrum, with preliminary Philips VG5000 support added in v1.11.2 (September 2022) and an 8086 PC target listed as “in progress”. Counting is awkward, because most machines appear in several variants - different RAM sizes, different CPUs, different video chips - and a single build target often covers a family: the project describes its own coverage as “around twenty targets”, while the v1.18 release notes describe conditional compilation for eleven different CPUs.
Code quality. Successive releases have concentrated on making the emitted assembly smaller. Peephole optimization of generated code first appears in v1.3.2-beta (October 2021), without a CPU named in the release notes; v1.7.2 added it for the 6809-based Thomson MO5 and Olivetti Prodest targets, and v1.16.4 reports improved peephole optimizers for the MOS 6502/6510/8502 and Zilog Z80. The release notes for v1.16 (March 2024) claim “an improvement of up to 30% in the size of the final executable, with the same source”, attributing it to better handling of integer variables and constants, optimized implicit conversions and elimination of unused temporary variables. The release notes give no benchmark, baseline program set or measurement conditions for that figure; it is the project’s own claim about compiled output size rather than an independently verified result, and it concerns code size, not execution speed.
Convergence with classic BASICs. Later versions have moved toward compatibility with the
dialects of the 1980s rather than away from them. Version 1.15.1 (November 2023) added
PRINT@, DATA/READ/RESTORE, PMODE, PCLS and tolerance for the loop variable in
NEXT. Version 1.16.4 (September 2024) enrolled the compiler in the “TSB Project”, aiming
to bring the commands and syntax of Simons’ BASIC and TUNED Simons’ BASIC into ugBASIC, and
version 1.17 (January 2025) added an OPTION DIALECT ATARI BASIC directive.
Current relevance
ugBASIC is actively maintained. Version 1.18.1 was released on 29 May 2026, and the repository was still receiving commits in September 2026. The compiler is Apache 2.0 licensed and written in C, so it builds on modern Linux and Windows hosts; precompiled binaries and a Windows IDE are distributed through the project site and itch.io, and a browser sandbox lets newcomers compile without installing anything.
The community around it is small but visible in the European retrocomputing scene. Release announcements are carried by outlets such as Genesis8 Atari, entries written in ugBASIC appear regularly in the annual BASIC 10Liner Contest, and Spedaletti publishes both a continuously revised user manual and tutorial books on writing games with the language. The DOJO networking protocol, first implemented in v1.16.4 in September 2024 and extended over FujiNet the following March, is an unusually ambitious piece of scope for a hobby retro compiler - though the project still describes it as being reworked.
Why it matters
Cross-development kits for 8-bit machines are not new - cc65, z88dk and similar toolchains have existed for decades - but they are overwhelmingly C toolchains, and they generally target one CPU family. ugBASIC is unusual in two ways: it chooses BASIC, the language these machines actually shipped with, and it treats portability across radically different video and sound hardware as the central design problem rather than an afterthought.
Its “isomorphism” is a genuine, articulated position in a debate that portable-software design has been having since the 1970s: whether to hide the differences between machines or to map onto them. ugBASIC argues, with a working compiler as evidence, that on constrained hardware the second approach is the only one that survives contact with the target - and that a language dismissed as a beginner’s toy in 1982 turns out to be a reasonable front end for generating tight assembly across eleven different processors forty years later.
Timeline
Notable Uses & Legacy
BASIC 10Liner Contest entries
The project maintains a dedicated page for the annual BASIC 10Liner Contest, noting that ugBASIC entries cannot compete in PUR-80 because it is not a native BASIC, but are eligible for PUR-120, EXTREME-256, SCHAU and PLUS. Spedaletti's own entries include PICK THE STAR (2023 contest), FALLING BALLS (2024) and BEYOND THE DOOR and BEAUTY CONTEST (2025), each shipping as binaries for several machines from one source.
4GRAVITY!
A Connect Four clone with its own GitHub repository, written in ugBASIC and released in 2021 for the 'Forza 4' challenge of the RetroProgramming Italia group. The v1.1 release notes (October 2021) list versions for the Commodore 64, Dragon 64 and Atari 400/800, and the repository carries per-target resource sets for the Atari, Commodore 128 Z80 mode, TRS-80 Color Computer, Dragon 32/64 and ZX Spectrum.
SOKO64+ and PUSHORI64+
Sokoban and pushing-puzzle games for 'many retrocomputers'. Both began as Commodore 64 games written in ugBASIC by Emanuele Feronato (SOKO64 and PUSHORI64); Spedaletti re-worked each source so that, per the project READMEs, it builds for every supported target 'with just a single source code'. Each is maintained as its own open-source repository, with binaries on itch.io.
ugBASIC USER MANUAL and the tutorial books
Spedaletti publishes a frequently updated user manual on itch.io along with tutorial books - '3 Easy Pieces' (learning to write videogames with ugBASIC), 'a less easy piece' and 'shooting star' - each listed on itch.io in both English and Italian editions ('3 pezzi facili', 'un pezzo meno facile', 'stella cadente'). An online version of the manual and a generated reference manual are hosted on the project site.
UGBASIC-IDE and the web sandbox
A desktop IDE is released in lockstep with the compiler and gained autocompletion and inline help in version 1.15 and source-level profiling in 1.11.1. A browser-based sandbox at sandbox.ugbasic.iwashere.eu lets people compile and run ugBASIC programs without installing a toolchain.
DOJO protocol networking
ugBASIC ships a networking protocol called DOJO, first implemented in v1.16.4 (September 2024). The v1.17.1 release notes describe simplified instructions for creating rooms 'with the possibility of having up to 256 communication channels each', available over FujiNet and, in general, any device supporting serial communications - though FujiNet support is noted there as covering only the atari and coco targets. The manual describes the feature as undergoing a major overhaul, with specifications that may still change.