GPRX 3000
A CPU that does not exist, with three registers of any size and no memory at all.
xfix, 2016 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
xfix made GPRX 3000 in 2016 as the instruction set of a made-up CPU. It has three registers, A, B and C, that hold whole numbers of any size and never go below 0. There is no memory and no stack. All the work happens in A, and the only way to reach B and C is x, which turns the three registers one place.
Read the story
A jump goes to a character position in the program, so a loop has to know the number of its own first character. There is no conditional jump either. A program computes where to go, often with a division that gives 1 or 0. The specification shows it is Turing complete by running iterated Collatz functions this way.
The machine
| Command | Does |
|---|---|
72 | Put the number in A |
+ - * / % | A becomes A plus, minus, times, divided by or modulo B |
x | A gets C, B gets A, C gets B |
g | Jump to the character at position A, counting from 0 |
p | Print A as a byte |
r | Read a byte and put it plus 1 in A, or 0 at the end of input |
Running past the last character, or a jump to the position just after it, ends the run. A result below 0, a division by 0, a jump further out and any other character, spaces and line breaks too, stop it with an error.
Example
The Hello world prints each character from its code.
The Hello world prints each character from its code. Then 51g jumps to 51, its own length.
The cat reads a byte plus 1, so the end of input is the only 0. It divides 1 by that value plus 1, which gives 1 only at the end, and turns the result into a jump to 24 to print the byte or to 29 to stop. The specification says its examples assume a line break at the end, and the cat needs it, as 29 is one past its 28 characters.
Patterns it teaches
- Counter machines: three registers of any size, as in a Minsky machine.
- Turing tarpit: nine instructions and computed jumps.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from GPRX 3000
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gprx-3000.
Command line
shib run gprx-3000 -e 'rx1+x1/x5*xx+xx2x-xx24+gxp0g
' --input 'cat'shib manual gprx-3000Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/gprx-3000.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org