Tonoco
Twenty-six boxes that each do one thing. A program wires them together and drops numbers in.
David.werecat, 2013 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
David.werecat made Tonoco in 2013. A program has three instructions. It can wire the output of one box to another, remove that wire, or send a number to a box. Everything else happens in the boxes, which are named A to Z. A adds, H prints a number, I skips the next instruction on a 0, Y and Z switch execution off and on again.
Read the story
When a box gives a value, the value goes to every box it is wired to in alphabetical order, and each of those finishes its own chain before the next one gets it. The specification says such a network could run on real computers instead of the virtual one in its interpreter.
The machine
| Instruction | Does |
|---|---|
Cxy | Wire the output of box x to box y |
Dxy | Remove that wire |
Sxn | Send the integer n to box x |
| Box | Does |
|---|---|
A S M D P | On each two inputs give the first + - * / % the second |
B R X N | And, or and xor of two inputs, not of one |
V W | -1 if the first is less or greater than the second, else 0 |
C K | Read a character code, or a line as a number |
H Q | Print a number or a character |
T G | Store the second input at the address in the first; read an address |
U O | Push; pop |
E | Give the input before this one |
I | Skip the next instruction when the input is 0 |
Y Z | Switch execution off one level deeper; switch it on again at that level |
L J | Make a label at this instruction; jump to one |
F | End |
Values are 32-bit integers. While execution is off or skipped, a box still makes labels and Y and Z still count levels, but nothing else happens and C and D instructions are ignored.
Example
The cat wires C to N and Q, and N to I.
The cat wires C to N and Q, and N to I. C reads a character and its code goes to N first. N inverts it, which gives 0 only for -1, the end of the input. Then I skips the rest of the chain, so Q never prints the -1, and it skips the jump back, so the program ends.
The Fibonacci keeps the last number on the stack and the next one in memory cell 0. W compares each new sum with 10000, and once it is bigger I no longer skips F.
The specification also has a greeter that keeps a name in memory and a Deadfish interpreter that takes one command a line.
Patterns it teaches
- Stack machines: U and O give the network a stack, and the Fibonacci keeps its last number there.
Further
See also
Object-oriented paradigm
Stack-based
Write your own in Run Convert a program from Tonoco
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tonoco.
Command line
shib run tonoco -e 'CCNCCQCNISL0SC0SJ0' --input 'cat'shib manual tonocoSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/tonoco.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org