contents/xyw.md
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
----- code: xyw sourcehut: xyw home: /xyw/ site: "https://xyw.2c.fyi" title: "xyw" subtitle: "A minimal virtual machine and assembler targeting terminals, inspired by Uxn." summary: "xyw is a simple and minimal virtual machine and assembler inspured by Uxn, that aims at providing a low-level, future-proof way to create terminal applications." content-type: project active: true version: 320-1 conver: true branch: master changelog: true stage: prototype license: MIT ----- xyw is a specification for a minimalist virtual machine programmable via a concatenative, assembly-like language. It is implemented primarily as a [stack machine](https://en.wikipedia.org/wiki/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](https://100r.co/site/uxn.html) and its fork [Bedrock](https://benbridle.com/projects/bedrock 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](https://en.wikipedia.org/wiki/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. |