`
` is a minimalistic esoteric language created by User:Iamcalledbob that was designed to have only two instructions, while being somewhat usable for computation.
Description
There is an infinite tape, which has cells. Cells can contain a number, negative or positive. The maximum value of a cell isn't specified. If anything is assigned to cell number 0, the ASCII character of that thing is printed to STDOUT.
Instructions
Syntax | Function |
---|---|
A`+B | Set address A to the value B. |
A`B | Set address A to the value of address B. |
+A`+B | If the latest assigned value equals A, jump B instructions in code relatively. Or else do nothing. B can be a negative in order to jump backward. |
+A`B | If the latest assigned value equals A, jump the value of address B instructions in code relatively. Or else do nothing. Value of B can be a negative in order to jump backward. |
Any invalid instruction | Is ignored other than to separate instructions apart. |
When jumping to or just reaching the end of the file, program stops. It's not specified what happens when you jump below the instruction 0.
Computational Class
` cannot access cells with addresses that aren't specified literally in the program (or the initial state of the tape), and cannot set cells to values that aren't specified literally in the program (or the initial state of the tape). As such, assuming that the initial tape contains only finitely many different values, ` is a finite-state machine.
Examples
Hello, world!
0`+72 0`+101 0`+108 0`+108 0`+111 0`+44 0`+32 0`+119 0`+111 0`+114 0`+108 0`+100 0`+33
Infinite loop
1`+1 +1`+-1
Cat
Assuming cell one is the input stream. 0`1 2`+0 +0`+-2
Truth-machine
Assuming cell one has the input. 0`1 +1`+-1
NAND gate
Assuming cell one and two have the inputs. 1`1 +0`+5 2`2 +0`+3 0`+48 +48`+2 0`+49
Interpreter
This is an interpreter in Python:
import sys l = open(sys.argv[1]).read().split("\n") ptr = 0 addrs = {} last = 0 while ptr < len(l): try: # See if line is valid L, R = l[ptr].split('`') int(L) int(R.lstrip("+")) except: ptr += 1 continue if L[0] == '+': if R[0] == "+": if last == int(L[1:]): ptr += int(R[1:]) else: if last == int(L[1:]): ptr += addrs[int(R)] else: if R[0] == "+": if L == "0": print(end=chr(int(R[1:]))) addrs[int(L)] = int(R[1:]) last = int(R[1:]) else: if L == "0": print(end=chr(int(R[1:]))) addrs[int(L)] = addrs[int(R)] last = addrs[int(R)] ptr += 1