esolang

Full 0

Seven commands on a ring. A call runs whatever the pointer happens to rest on.

Tslil Clingman, 2007 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 7 known programs · Test method

Run it

Expected: Hi

The idea

Tslil Clingman devised Full 0 in late 2007, pronounced Full Circle or Full Oh. It wanted few commands but many possible instructions. There is one way to call a command, [x], and it calls the one under a pointer that walks round a ring of seven. So before every call the program steers the pointer, and the same [a0] can add to a0, print it, read into it or jump to it.

The machine

The ring holds Inc, Dec, Jmp, Out, In, If and Var, numbered 0 to 6. The pointer starts on Inc going forward, and after each call it moves one place on.

BlockDoes
{x}Move the pointer x places in its direction
~Turn the direction round
@Put the pointer back on Inc, going forward
[x]Call the command under the pointer with x
CommandTakesDoes
Inc, Dec[a0]Add or take 1
Jmp[8], [!-6]Go on after block 8, or after the block 6 before this one
Out[a0], [#a0]Print a byte, or the number in decimal
In[a0]Read a byte
If[(a0>0)(...)]Run the blocks inside when it holds; =, /> and /= also work
Var[(a0)(?H)]Set a variable to a number, a variable or a character

There are 26,000 variables, a letter and a number up to 999, and each holds any integer. Jumps count blocks only. An If is not a block, but the blocks inside it are. The programs need the count to start at 1. Inc, Dec, a test and a jump on unbounded variables make a counter machine.

Example

Hello World starts like this.

Hello World starts like this. {6} steers to Var, which sets a0 to H. The pointer then wraps round to Inc, {3} steers to Out and [a0] prints.

The multiplication adds 1 to a2 four times, three times over. [!-6] goes back to the @@ that starts the inner loop, and [#a2] prints the result in decimal.

Expected: 12

The cat reads into k1 and, while k1 is not a line feed, turns round to Out, prints it and jumps to the start.

Expected: cat

The specification also divides 12 by 5 into 2 r 2, prints 13 Fibonacci numbers and gives a brainfuck interpreter, which all run. Inside the interpreter's scan back from ] to its [, the loop's own jump lands one block early, on Out, so a loop that goes back also prints its bracket depth as bytes. The Collatz program prints 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 and then loops on 4 2 1, as written.

Patterns it teaches

Further

Also in Hostile

Write your own in Run Convert a program from Full 0

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: full-0.

Command line

shib run full-0 -e '@{4}[k1][(k1/=10)(~{2}[k1][-1])]' --input 'cat
'
shib manual full-0

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/full-0.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org