xyw

A minimal virtual machine and assembler targeting terminals, inspired by Uxn.

ConVerv300-7
LicenseMIT

xyw is a specification for a minimalist virtual machine programmable via a concatenative, assembly-like language. It is implemented primarily as a stack machine, but it also provides four “registers” that can be used by most instructions by specifying dedicated modes, to reduce the need of stack juggling operations common to languages like Forth.

Rationale

xyw is heavily inspired by Uxn and its fork Bedrock, but aims at being even simpler and easier to learn. In particular, it differs from Uxn because:

  • its syntax is more minimalist: no runes or sigils except for . for directives, $ for hex numbers and % for binary numbers (all these are inspired by 6502 assembly syntax).
  • it includes specific modes to operate on registers.
  • it exposes more basic and simpler devices by default.
  • it only exposes a single stack to the user (corresponding to Uxn’s working stack).
  • it has a concept of relocatable zero page (direct page), partly borrowed from 6809 assembly.
  • it maps devices to addressable memory.

In a nutshell, if Uxn can be used to create small multimedia programs that could be running on low-end laptops and small gaming handhelds, xyw can create programs that could hypothetically run on the equivalent of a 1980s pocket computer or early terminal.

Key Features

  • up to 64KiB of addressable memory.
  • two stacks, one used internally by the system to manage subroutines, and one accessible to the user.
  • 32 instructions, each with up to three different modes to operate on registers and on 16bit values.
  • Two 8bit registers called x and y, and two 16bit registers accessible via the w mode.
  • Up to a maximum of 16 memory-mapped devices, each with up to 16 reserved bytes (like Uxn).
  • Event-based operation, similar to Uxn.
  • Direct page accessible via a single byte, set by default to the device page, that can be moved to different locations in memory.
  • A few assembly-inspired directives, which are also used to implement labels.
  • Support for integers expressed in hexadecimal or binary notation.