TwoStep
Every statement is two characters, a command and a digit. The whole memory is one byte.
2006 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
TwoStep is from 2006. A program is read two characters at a time. The first is one of 12 commands and the second is a digit from 0 to 9, so arithmetic can only add, subtract, multiply or divide by a single digit. To print a letter the program builds its code in the one byte of memory, 72 for H as 6 times 2 times 6. A space is the command that does nothing, which leaves its second character free, and that is how the specification writes a comment.
The machine
| Command | Does |
|---|---|
+ - * / | Add, subtract, multiply or divide the memory by the digit |
> < | Run the next statement if the digit is less or greater than the memory, else skip it |
) ( | Go back one statement if the digit is less or greater than the memory, else skip the next |
[ ] | Print the memory as a character, or read a character into it |
. | Stop |
| space | Nothing |
The memory wraps around 256, and dividing by 0 does nothing.
Example
The Hello World opens with 14 statements that each start with a space, the comment.
The Hello World opens with 14 statements that each start with a space, the comment. *0 clears the memory for 7 of its 13 characters. The other 6 step from the one before, as +7 turns e into l, or print it again. The cat reads one character and prints it.
The loop *0+6*4*5[ )0. builds 120, an x, and prints it. Then )0 goes back to the print as long as 0 is less than the memory, which is forever.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from TwoStep
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: twostep.
Command line
shib run twostep -e '] [ . ' --input 'x'shib manual twostepSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/twostep.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org