UberGenes
Aubergine with the restrictions taken off. Where the program stops, it prints itself.
Quintopia, 2015 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Quintopia made UberGenes in 2015 as a mostly backwards compatible extension of Aubergine. The goal was a small footprint, counted as the length of a program plus the length of its interpreter. The reference interpreter in Python is 907 bytes.
Read the story
As in Aubergine, the program's bytes are its memory, and an instruction is three cells, an operator and two arguments. UberGenes gives every letter a register, lets digits stand for their value, adds eight operators, and lets programs read and write memory beyond their own end.
The last change is a golfing trick. When the instruction pointer lands on something that is not an operator, the run prints the cells from there until one holds 0, and then it stops. A program that starts with any other character prints itself, so Hello, World! is both a Hello World and a quine.
The machine
| Operator | Does to the first argument |
|---|---|
= + - * | Set it to, add, subtract or multiply by the second |
/ % | Divide by the second, or take the remainder, rounding down |
\| & ^ | Or, and, xor with the second |
> < | 1 if it is greater or less than the second, else 0 |
: | Jump, setting i to the first when the second is not 0 |
| Argument | Is |
|---|---|
a to z | 26 registers, 0 at first |
i | The instruction pointer |
o | Read a byte when second, print when first |
A to Z | The cell the register points at |
0 to 9 | That number |
After every instruction i grows by 3, also after a jump. Cells beyond the program hold 0.
Example
The second program, also from the specification, prints the larger of two characters.
The second program, also from the specification, prints the larger of two characters. >cb leaves 1 or 0, and multiplying by it keeps only the winner.
The even or odd test reads digits until a non-digit and keeps the last one in cell 0, over its own first instruction. Then +iA jumps 0 or 5 cells further, onto the text Even or Odd, which prints itself.
Patterns it teaches
- Self-modifying code: capitals write anywhere, the program included.
- Code as data: the parity test takes 61 from its own
=and 89 from aY. - Quine: text that is not code prints itself.
- Turing completeness: unbounded registers and memory, as in Aubergine.
Further
See also
Self-modifying
Write your own in Run Convert a program from UberGenes
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: ubergenes.
Command line
shib run ubergenes -e 'Hello, World!'shib manual ubergenesSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/ubergenes.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org