Running Varvara on a Pi Pico 2

ibobev1 pts0 comments

Running Varvara on a Pi Pico 2 - jaeblog jaeblog

You are using an outdated browser. Upgrade your browser today or install Google Chrome Frame to better experience this site.

Jul 11, 2026 |<br>0 comments

Running Varvara on a Pi Pico 2

What’s a "Varvara" and why does that pi pico 2 look a little different? Let’s dive into that!

Varvara is a specification for a computer system, which uses the Uxn virtual machine and describes how things like a display, mouse, keyboard and such should react. Uxn, in term, is a spec for a virtual machine or virtual CPU. It’s a stack based 8 bit CPU that is meant to be easy to learn and emulate.

It’s essentially a graphical computer specification! The goal is to have an easy to implement and emulate computer with it’s own programming language, so programs can be written once and run on everything. And the computer is made to be easy to program for, as all the devices like files, screen and such are very abstract.

For example, there is no notion of a file system. There are just commands to read, write and delete files. The emulator handles the rest. For the display, to draw a sprite, the address of the sprite is placed in the right location and then a command is issued to draw it.

This feels very much like an 8 bit home computer done right, not having to care too much about hardware limitations of that era. There is also a ton of programs and guides for it, from small tools like a calendar and notepad to quite some games. There is also a great tutorial on programming for the Varvara computer here which I highly recommend to check out!

Of course, my brain went: Huh. can I run this on a micro-controller?

So I tried in the past using a Pi Pico, but it just wasn’t meant to be. The Pi Pico 1 felt just a bit too small and limited. But then the Pi Pico 2 launched, with twice the RAM. So let’s try again :)

OK and make a custom RP2350 board because I got annoyed at the Pi Pico 2, can’t have a project without a little yak shaving!

Uxn/Varvara nitty gritty

First of all, let’s look at Uxn! There is a spec on what this all contains. Essentially, we need to emulate an 8 bit stack CPU. This means there are no registers, instead there is a working stack and a return stack, each is 256 bytes big. By default, there is 64KB of memory.

Uxn has 32 instructions, and as this is a stack based computer, they all operate on the stack. For example, the ADD instruction adds the top two values of the stack and pushes the result to the stack.<br>Each instruction can have a flag to operate in short mode to operate on 16 bit numbers, a flag to use the return stack instead of the working stack, and a flag to not remove the values read from stack.<br>This means every instruction is just a single byte big! 5 bit for the operand and 3 bits for the flags.

Luckily, there are a ton of great, tried and tested, implementations for Uxn in C, which should just run on any machine with a C compiler and enough RAM.

Varvara is a tad more involved though!

Turn the CPU into a computer

Varvara is the spec for the computer system so to say, think mouse, keyboard, display, sound and more. It’s divided into 16 possible devices, each having 16 bytes of addressable memory called ports. From a programmers point of view, it’s very similar to memory mapped peripherals that many micro-controllers have.

Currently, there are 8 devices in Varvara:

System

Console

Screen

Audio

Controller

Mouse

File

Datetime

Each device can have a vector, essentially an interrupt. When a certain condition is met, Uxn will jump to the address stored in the vector. For example, for the Mouse, every time movement or a button press is detected, the system should jump to the address stored in the Mouse vector.

This is the mouse device. To read the position of the mouse, you would just read address 0x92 and 0x94! The pressed buttons can be read from the "state" port.

Most devices are fairly straightforward. The Controller handles a controller or keyboard. Mouse handles a mouse and so on. A few more annoying ones are the System, Screen, Audio and File.

System

The system device handles a few system things. It contains direct access to the stacks, contains the colour information for the Screen and it has the option to address more memory!

Yes, this 8 bit machine can have more then 64KB of memory. Via the expansion port in the system device, memory can be copied to/from other banks to the memory of the machine.

File

The file device can read, write and append to files, and also delete files. Varvara does not specify any file system or storage format. That’s all up to the machine emulating this. A Pi Pico has quite a bit of on board storage, but for easy of file transfer I decided that a microSD card is much much easier.

Varvara has two file devices, so in theory two storage options can be added. For one one microSD card is fine, but having one for programs and one for files sounds nice. Or use the internal storage for programs, and the...

varvara system stack pico computer mouse

Related Articles