Category:Uxntal: Difference between revisions

From Rosetta Code
Content added Content deleted
(Create page with information about Uxntal)
 
m (Tweaks for clarity)
 
Line 9: Line 9:
For I/O, Uxn features two instructions <code>DEO</code> and <code>DEI</code>, 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.
For I/O, Uxn features two instructions <code>DEO</code> and <code>DEI</code>, 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 do not accept flags are: <code>BRK</code> (break), <code>JCI</code>, <code>JMI</code>, <code>JSI</code>, (immediate jumps), <code>LIT</code>, <code>LIT2</code>, <code>LITr</code>, <code>LIT2r</code> (integer literals). The flags on the regular instructions are: <code>2</code> (short mode), <code>r</code> (use return stack), and <code>k</code> (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.
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: <code>BRK</code> (break), <code>JCI</code>, <code>JMI</code>, <code>JSI</code>, (immediate jumps), <code>LIT</code>, <code>LIT2</code>, <code>LITr</code>, <code>LIT2r</code> (integer literals). The flags on the regular instructions are: <code>2</code> (short mode), <code>r</code> (use return stack), and <code>k</code> (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 ==
== Syntax ==


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


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


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

Latest revision as of 08:55, 29 February 2024

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.