Two Four
Four instructions, each written as two bits, on a field of sixteen bits.
00Her0, 2022 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 9 known programs · Test method
Run it
The idea
00Her0 made Two Four in 2022 and named it for its four instructions, each written as two bits. They work on a field of 16 bits, often drawn as a 4 by 4 square, with one pointer called the soba, the Selected One Bit Accumulator.
Read the story
Each line of the program is a tape. The program runs once from top to bottom and then shows the field. There are no loops, so every program stops, and 16 bits are all the memory there is. The specification says it is almost certainly not Turing complete.
The machine
| Instruction | Does |
|---|---|
00 | If the bit at the soba is 0, move 4 on; if 1, move 1 on |
11 | Flip the bit at the soba; every second 11 in a row also moves 1 on |
10 | Move the soba back to 0 |
01 | If the bit at the soba is 0, skip the rest of this line |
The soba wraps from 15 back to 0. The input fills the field from bit 0, as the specification's input layer does. The output is the field as the specification's interpreter prints it, four bits a row and then ***.
Example
The AND reads bits 0 and 1 and writes bit 2.
The AND reads bits 0 and 1 and writes bit 2. On 11 the first 00 moves to bit 1, the 01 passes, the second 00 moves to bit 2 and 11 sets it.
The OR takes two lines. The first sets bit 2 only when both inputs are 0, and the second always flips bit 2, so it ends up as a or b. It leaves the input bits changed.
Patterns it teaches
- Encoding tricks: the instruction set is spelled in its own data, two bits each.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Two Four
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: two-four.
Command line
shib run two-four -e '11' --input '1'shib manual two-fourSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/two-four.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org