23
A program is a column of blank lines. Their lengths are the numbers in memory, and the numbers are the program.
Philipp Winterberg, 2002 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Philipp Winterberg made 23 in 2002. The name is 32 backwards, the code of the space character. In its default notation a program is only spaces and line breaks. Each line's length is one value in memory, read from the bottom line up, and the last line is dropped. 23.ixsy writes the same lines with x, and 23.dezsy lists the values with commas.
Read the story
Memory holds code and data alike, so a program can change itself. Opcode 1 even deletes cells and shifts everything after them back.
The machine
Each value is read modulo 32. A value that is no opcode does nothing.
| Opcode | Does |
|---|---|
1 n | Delete n cells, starting with the n itself |
8 n | Add n to the index |
10 n i | Take n from cell i |
16 c 17 n ... | Print c; print the next n values |
18 i 19 i n | Print cell i; print n cells from i |
20 21 n | Print the cell at the index; print n cells from there |
22 v 23 i | Print v or cell i in decimal |
27 i j | Jump to i if cell j is not 0 |
30 i 31 | Start one more instruction pointer at i, or at the cell under the index |
Every round each instruction pointer takes one step, oldest first. A pointer that meets the value 0 ten times in a row dies, and the program ends when none are left. Values are cut to 255 only when loading.
Example
Opcode 17 prints the next twelve values as characters.
Opcode 17 prints the next twelve values as characters. After them memory is 0, and the pointer dies on its tenth zero.
The same machine with lines of x. The bottom line has 22 of them, so the first value is 22, which prints the value after it, 2, in decimal.
A test of opcodes 16 to 23 prints each number with its own opcode. Its run of ten zeros kills the pointer before it reaches the data behind them.
The specification also has a 99 bottles of beer that counts down with opcode 10 and jumps back with 27 until the count is 0, then deletes its own text so the pointer runs into zeros.
Patterns it teaches
- Camouflage: the default program is blank.
- Self-modifying code: opcode 10 changes any cell and opcode 1 deletes them.
- Code as data: the text it prints sits in the same memory as the code.
Further
See also
Concurrent programming
Self-modifying
Write your own in Run Convert a program from 23
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 23.
Command line
shib run 23 -e '17,12,72,101,108,108,111,32,87,111,114,108,100,33'shib manual 23Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/23.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org