Affine Mess
25 bits and one command, XOR. Input, output and AND are places in memory.
Caenbe, 2020 · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Caenbe made Affine Mess in 2020, inspired by XOṘ Mạchịne. The programmer may use XOR and NOT freely, but AND only where the language allows. A program is a list of pairs of bit names, and the pair ab sets a to a XOR b. There is no other command. The whole program runs again and again until bit z is 1.
The machine
The bits are named a to z without l, 25 in all, and 1 is a bit that is always 1, so a1 flips a. Text between 11 and 11 is a comment.
| Bits | Role |
|---|---|
a to h | Free, and one side of the AND |
i to q | The next input byte, 0 at the end, and the other side of the AND |
r to y | The output byte, then the AND |
z | Halt when 1 |
Each pass reads a byte into i to q, runs every pair, prints r to y, stores a to h AND i to q in r to y, and stops if z is 1. A byte has its highest bit first. Only a to h and z keep their value from one pass to the next on their own.
Example
The truth machine.
The truth machine. z becomes m XOR q, which is 1 for the character 0 and 0 for the character 1, and t, u and y spell the digit. On 1 it prints 1 forever.
The Hello World, without its two comments. A single 1 slides from a to h, one bit each pass, and every row XORs one letter into the output while its bit is on. When the 1 reaches h it also sets z.
The cat copies each byte to the output and ANDs bits of the inverted byte over three passes to see when a 0 came in. It halts three passes after the first 0, so it prints four 0 bytes after the text, as the specification says.
Patterns it teaches
- One instruction: XOR is the only command, so a program is a list of pairs of names.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Affine Mess
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: affine-mess.
Command line
shib run affine-mess -e 'zm zq t1 u1 y1 yz' --input '0'shib manual affine-messSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/affine-mess.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org