Category:Uxntal

From Rosetta Code
Language
Uxntal
This programming language may be used to instruct a computer to perform a task.
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using Uxntal.

Uxntal is the assembly language for the Uxn virtual machine. The VM has 64KiB of addressable memory, two 256-byte stacks (data and return), and a 256-byte block of I/O ports, divided into 16 devices with 16 ports each. The Uxntal assembler features sub-labels, simple lambdas, user-defined macros, and shorthands for common immediate operations.

Uxn VM

The Uxn VM relies on stacks for managing data and control flow. There are two stacks, each containing up to 256 bytes - one for general data, and one for return addresses (or anything else you want to temporarily store there). Additionally, data can be read and written anywhere in the 64KiB main memory, including to parts of the code - self-modifying code is often useful in Uxn.

For I/O, Uxn features two instructions DEO and DEI, which are used to access a separate block of 256 8-bit registers, split into 16 devices of 16 ports each. The Varvara specification defines a standard set of computing devices, including keyboard, mouse, and controller input, and video + audio outputs.

The 256 opcodes are divided into 8 special instructions, and 31 regular instructions with 3 flags each. The special instructions, which can't take additional flags are: BRK (break), JCI, JMI, JSI, (immediate jumps), LIT, LIT2, LITr, LIT2r (integer literals). The flags on the regular instructions are: 2 (short mode), r (use return stack), and k (keep operands). The main instructions include general stack operations, load and store operations, arithmetic operations, and jumps, as well as the two I/O instructions mentioned above.

Syntax

Instructions are written in uppercase, followed by any combination of the three flags 2kr. Hex values are written with lowercase a-f.

Code can be placed at specific addresses with the | rune, which is especially important for assembling the reset vector at address 0x100 (|0100) and for defining devices and zero-page variables. Padding can be inserted with the $ rune.

Labels are created with @ and &. The difference is that @ creates a label with the given name, while & creates a sub-label by prefixing the most recent @label and a slash.

For further details on Uxntal syntax, see the syntax page on the XXIIVV wiki.