RedDust

From Esolang
Jump to navigation Jump to search
RedDust
Paradigm(s) imperative, register-based, virtual assembly
Designed by SyntaxError!
Appeared in 2025
Memory system register-based
Dimensions one-dimensional
Computational class virtual machine language
Major implementations RedDust VM
Influenced by assembly language
bytecode
CHIP-8
File extension(s) .redd

RedDust is a register-based virtual assembly language that runs on a simple bytecode virtual machine. It was originally designed to run on a redstone-based 4-bit CPU implemented in Minecraft. The name "RedDust" references the redstone item in the game, which is used to build circuits and systems.

The RedDust interpreter can be downloaded on the official GitHub repository.

Instructions

The language has 16 instructions, represented by single-character codes. The 10th code uses hexadecimal notation.

The requirement of four fields ensures a uniform instruction size, simplifies parsing, and allows simple CPU designs to run without problems. Omitting or adding values ​​can lead to undefined behavior.

Instruction Table
Code Command Description Example
0 HALT Terminates program execution. 0;0;0;0 // ends the program
1 INPUT Reads a number from the user (if B=0) or uses an immediate value (B≠0) and stores it in A. 1;1;5;0 // stores 5 in R1
2 OUTPUT Displays the value stored at address A. 2;1;0;0 // shows value of R1
3 ADD Adds (mem[A] + mem[B]) and stores the result in C. 3;1;2;3 // R3 = R1 + R2
4 SUB Subtracts (mem[A] - mem[B]) and stores the result in C. 4;1;2;3 // R3 = R1 - R2
5 DIV Divides (mem[A] ÷ mem[B]) and stores the result in C (integer division). 5;1;2;3 // R3 = R1 / R2
6 MUL Multiplies (mem[A] × mem[B]) and stores the result in C. 6;1;2;3 // R3 = R1 * R2
7 COND JUMP Jumps to line C if mem[A] == B. 7;1;3;8 // If R1 == 3 → jump to line 8
8 JUMP Unconditionally jumps to line A. 8;A;0;0 // jump to line A (10)
9 CLEAR Sets mem[A] to zero. 9;1;0;0 // R1 = 0
A RANDOM Stores in A a random number between B and C. A;A;B;1 // R1 = random value (A–B)
B CMP GREATER Compares mem[A] > mem[B] and stores 1 (true) or 0 (false) in C. B;1;2;3 // If R1 > R2 → R3 = 1, else 0
C CMP EQUAL Checks whether mem[A] == mem[B] and stores 1 (true) or 0 (false) in C. C;1;2;3 // if R1 == R2: R3 = 1
D MOVE Copies mem[A] to mem[B]. D;1;2;0 // R2 = R1
E INC/DEC Increments (flag=1) or decrements (flag=0) mem[A]. E;1;1;0 // R1++ | E;1;0;0 // R1--
F WAIT Pauses execution for A seconds (HEX → decimal). F;A;0;0 // waits 10 seconds

Syntax

RedDust's syntax is designed to be minimalist and predictable, with no abstractions. Prior experience with assembly language and registers is recommended to understand it.

Each line of code must have 4 values separated by semicolons (;), for example:

3;1;2;3 // R3 = R1 + R2

Comments begin with two slashes (//) and are recommended to improve readability and understanding.

Program Behavior

RedDust programs consist of lines with exactly four values separated by semicolons (;). Each line corresponds to a single instruction. This strict format is required to ensure predictable parsing and execution by the RedDust virtual machine.

Output

Most instructions do not produce direct output, except for the OUTPUT instruction, which displays the value stored at the specified address. Programs may also produce side effects by modifying the contents of registers or memory.

It's not possible to output text, just one-character hexadecimal numbers.

Errors and Exceptions

The virtual machine performs minimal runtime checks. Common errors include:

  • Using an invalid instruction code (any value outside of 0 to F in hexadecimal).
  • Accessing a register or memory address that does not exist (<R1 or >R256).
  • Performing division by zero (DIV instruction with B=0).

In these cases, the program may stop unexpectedly, produce incorrect results, or display an error, depending on the RedDust virtual machine implementation.

Examples

Adder

1;1;0;0   // input first number and saves on R1
1;2;0;0   // input second number and saves on R2
3;1;2;3   // add R2 value to R1 and saves on R3
2;3;0;0   // output the value of R3 (result)
0;0;0;0   // exit program

Guessing game

1;1;0;0   // input a number and saves on R1
A;1;F;2   // pick a random number between 1 and F (15) and saves on R2
C;1;2;3   // if R1 == R2 saves 1 on R3, if not, saves 0
2;3;0;0   // output R3 (result)
0;0;0;0   // exit program