esolang

RedDust

An assembly for a 4-bit CPU built out of redstone in Minecraft, sixteen instructions in four hex fields.

SyntaxError!, 2025 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: B

The idea

SyntaxError! made RedDust in 2025, first for a 4-bit CPU built from redstone in Minecraft. It is named after redstone dust. Every line is exactly four hexadecimal values split by semicolons, so that a simple CPU can read each instruction the same way. The first value is the instruction, and the other three are registers, numbers or line numbers.

Read the story

It cannot print text. The specification says the only output is a hexadecimal number of one character.

The machine

CodeDoes
0Halt
1;a;bR[a] = b, or a number from the input if b is 0
2;aPrint R[a]
3 4 5 6 ;a;b;cR[c] = R[a] plus, minus, divided by, times R[b]
7;a;b;cJump to line c if R[a] equals b
8;aJump to line a
9;aR[a] = 0
A;a;b;cR[c] = a random number from a to b
B;a;b;cR[c] = 1 if R[a] is greater than R[b], else 0
C;a;b;cR[c] = 1 if R[a] equals R[b], else 0
D;a;bR[b] = R[a]
E;a;bAdd 1 to R[a] if b is 1, take 1 if b is 0
F;aWait a seconds

The specification leaves a few things open. Every value is four bits, so F plus 1 is 0, and each print is one character and a line feed. Lines count from 0. For A the specification's table and its two examples disagree; this implementation follows the examples. Its random numbers come from a fixed sequence, so a run repeats, and F does not wait.

Example

The adder reads two numbers and prints their sum in hex.

The adder reads two numbers and prints their sum in hex.

The guessing game compares the input with a random number from 1 to F and prints 1 on a match. A guess of 0 can never match.

Expected: 0

A countdown. Line 3 jumps out to the halt on line 5 when R1 reaches 0, and line 4 jumps back to the print on line 1.

Expected: 3 2 1

Patterns it teaches

  • Counter machines: registers, add and subtract one, and a jump on a value. With four bits a register only counts to 15, so the machine is finite.

Further

Stack-based

Write your own in Run Convert a program from RedDust

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: reddust.

Command line

shib run reddust -e '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' --input '3
4'
shib manual reddust

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/reddust.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org