LIMITED
Four commands, numbers without a bound and a jump to a line number.
DadoDev · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 7 known programs · Test method
Run it
The idea
DadoDev made LIMITED to have one of the smallest instruction sets possible. There are four commands. Three change a variable and the fourth compares two values and jumps to a line. Every variable is a whole number with no bound, so the specification calls it a variation of the counter machine and Turing complete.
Read the story
Three more commands read and print. The specification leaves them out of the count, as a machine needs no I/O to be Turing complete.
The machine
| Command | Does |
|---|---|
SET x y | Set x to y |
ADD x y | Add y to x |
INV x | Multiply x by -1 |
CMP x op y n | Jump to line n if x op y holds, op one of == != < <= > >= |
INP x | Read a whole number |
OUT x | Print x as a number and a line feed |
ASC x | Print the character with code x |
Lines are numbered from 1, and an empty line counts. A value is a variable or a number. There is no subtraction, so a program subtracts by adding an inverted copy.
Example
The truth machine.
The truth machine. On 1 it jumps back to line 2 and prints 1 forever; on 0 it prints 0 and falls off the end.
Counting to a number read from the input. Line 5 jumps back to line 3 while the count is at most the maximum.
A triangle of asterisks. ASC 42 prints a star and ASC 10 a line feed.
The specification also has a Hello, World! of thirteen ASC lines and a multiplication by repeated addition, which both work.
Patterns it teaches
- Counter machines: named numbers, adding and a conditional jump.
- Turing tarpit: four commands, and
INVcould go too.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from LIMITED
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: limited.
Command line
shib run limited -e 'INP value
OUT value
CMP value == 1 2' --input '0'shib manual limitedSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/limited.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org