Sesos
Brainfuck, packed three bits at a time. Sequences that would be useless are reused to write numbers.
Dennis, 2016 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Dennis made Sesos in 2016. Its meaning is almost that of brainfuck: a tape of cells, a pointer, add and subtract, input and output, loops. The new part is the encoding. A Sesos binary is a string of octal digits, and each digit belongs to one of four groups.
Read the story
In brainfuck, +- or <> do nothing, so a sensible program never contains them. Sesos uses exactly those useless runs to write numbers. A 5 starts an addition, and the digits after it from the same group spell out the amount in a kind of base 3. A move works the same way in base 2. So add 72 costs a few digits instead of 72 plus signs.
People write Sesos in its assembly language, and that is what TIO runs.
The machine
| Assembly | Does |
|---|---|
add n / sub n | Change the current cell by n |
fwd n / rwd n | Move the pointer n cells right or left |
put / get | Print the cell as a byte, read a byte into it |
jmp … jnz | While the cell is not 0 |
nop … jnz | The same, but the body runs once before the first test |
jmp … jne | While a byte of input could be read into the cell |
The tape is endless in both directions. A loop that would start at the very top of a program and run around all of it would be skipped at once, so Sesos turns such a jmp … jnz into a reading loop.
Example
The program TIO uses for Hello World:
The program TIO uses for Hello World:
A cat. jmp first tests the loop's end, and jne reads a byte, so the body only runs when there was one:
A counter: cell 0 counts down from 3, cell 1 climbs from the digit 1:
This implementation runs the assembly only. The binary form and the set directives are left out, and so is any case the specification does not settle: a cell that leaves 0 to 255, since the reference can have 8-bit or unbounded cells, get after the input has ended, and a cell that jne could not read into. Those stop the run with a reason.
Patterns it teaches
- Encoding tricks: the meaning stays brainfuck, only the bits change. Useless sequences become the number syntax.
- Turing completeness: most brainfuck programs translate directly, and brainfuck is Turing complete.
Try this
- Print
Hiwith twoaddlines. - Write a program that prints its input in reverse. You will need
rwdin a loop. - Hard: print the numbers 1 to 9, each on its own line.
Further
See also
Sesos builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Sesos
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: sesos.
Command line
shib run sesos -e 'jmp
put
jne' --input 'cat'shib manual sesosSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/sesos.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org