XXIIVV
Uxn Sticker
Uxn Sticker

Uxn is a virtual machine with 32 instructions.

The Uxn ecosystem is a personal computing playground, created to host small tools and games, programmable in its own unique assembly language.

It was designed with an implementation-first mindset with a focus on creating portable graphical applications, the distribution of Uxn projects is akin to sharing game roms for any classic console emulator.

Memory

StacksWorking StackPointer1 byte
Data256 bytes
Return StackPointer1 byte
Data256 bytes
MemoryRAMPointer1 short
Data64kb
IODevicesData256 bytes

The CPU can tunnel through 128 subroutines and find its way back with its return stack. The CPU can connect to up to 16 devices at once, devices can be peripherals such as screens and controllers, or even an other Uxn CPU.

Design

Because Uxn was explicitly created to exist as software hosted on pre-existing hardware, the design was advised primarily by relative software complexity, not by how fast it could be made. Features were weighted against the relative difficulty they would add for programers implementing their own emulators.

Stack-machines, and postfix arithmetic, are ideal candidates for this scale of personal computing. Not only does it make for extremly basic compilers, the resulting succinct programs translates well to pen & paper computing.

—fizzbuzz.rom

With only 64kb of memory, it will never be capable of running Chrome, TensorFlow or a blockchain. It sucks at doing most modern computing, but it’s also sort of the point. It's more about finding what new things could be made in such a small system.

What's the benefit of Uxn over C, when just about everything has a C compiler?

While terminal utilities can be made portable, cross-platform graphical development is different. Even building projects for platforms with C compilers, such as Linux and Plan 9, will require a near total rewrites, whereas porting the thin layer that is the uxn emulator will allow that same rom file to be used on both systems.

C Implementation

The VM is implemented in about 140 lines of ANSI C, it lives at the core of the Varvara computer, Uxn is to Varvara, what the 6502 is to the Classic Nintendo.

static void
run(Uxn *u)
{
	Uint16 vec = PAGE_PROGRAM;
	uxn_eval(u, vec);
	while(uxn_eval(u, vec))
		;
}