Aubergine
Four instructions, four variables and one constant. The program is its own memory.
Boily, 2008 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Boily made Aubergine in 2008. A program is read as a list of integers, one per character, and that list is all the memory there is. Instructions and data share the same space, so a program reads and rewrites its own text.
Read the story
An instruction is three characters, an operator and two parameters. =aA means "set a to the value of the cell a points at". There are no literals except 1, so every other number has to be found in the program or built from it.
The machine
| Code | Does |
|---|---|
=xy | Set x to y |
+xy | Add y to x |
-xy | Subtract y from x |
:xy | If y is not 0, set the instruction pointer to x |
| Parameter | Is |
|---|---|
a b | Two variables, 0 at first |
A B | The program cell that a or b points at |
i | The instruction pointer, 0 at first |
o | Output when written, a character of input when read |
1 | The number one, only as the second parameter |
After every instruction i grows by 3, also after a jump. When i leaves the program, it stops. Values are integers of any size, negative ones too.
Example
The first program copies three characters of input.
The first program copies three characters of input. The second is the truth machine from esolangs.org. It stores the input character over its own first cell, prints it, and then loops back for as long as that character was 1.
Hello World by Quintopia keeps the greeting backwards at the end of the program and walks a down over it.
=aA reads the program's first character, =, which is 61; minus one gives 60, the last cell. Each round prints the cell at a, steps a back and rewrites the loop so it ends at the right moment. The newline in the middle is printed too, so the length of the text matters.
Patterns it teaches
- Self-modifying code:
Bcan point at any instruction and change it. - Code as data: constants are taken from the program's own characters.
- Quine:
-a1+a1=oA=Bi-BA:bB=iaplus a tab prints itself. - Turing completeness: unbounded cells can hold a two-register Minsky machine.
Further
See also
Self-modifying
Write your own in Run Convert a program from Aubergine
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: aubergine.
Command line
shib run aubergine -e '=oo=oo=oo' --input 'abc'shib manual aubergineSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/aubergine.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org