esolang

Esomachine

The office worker of Human Resource Machine, as a language. Every cell is locked until you unlock it.

Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hi

The idea

Esomachine is based on the game Human Resource Machine, where a worker carries one value in his hands between an inbox, an outbox and numbered tiles on the floor. In this implementation the hands are an accumulator and the floor is an endless tape of cells. Every cell starts locked, and a program has to unlock a cell before it may write to it.

Read the story

There are six instructions, one per line. Jumps go to a line number, so the program is read like a listing.

The machine

InstructionDoes
INDEX_STATE[s, n]Lock cell n (s = 0) or unlock it (s = 1)
INDEX_SET[n, v]Put v in cell n, which must be unlocked
HANDS_CONLANG[op, n]Accumulator + - * or / n
HANDS_JUMP[type, n]Go to line n if the accumulator is NEGATIVE, POSITIVE or ZERO; always for DONTCARE
HANDS_EXPECT[]Read a character code into the accumulator
OUTPUT[n]Print the character whose code is in cell n

Any number or address can be HANDS, the value in the accumulator, or [p], the value in cell p. A \ starts a comment. Lines count from 1, blank lines included. The specification leaves the end of the input open; it reads as 0.

Example

Unlock cell 0, then fill it and print it twice.

Unlock cell 0, then fill it and print it twice.

The truth machine. It keeps the input in cell 1 and takes 48 from the accumulator. On 0 that leaves 0, and line 5 jumps to the last line, which prints once. On 1 lines 6 and 7 print 1 forever.

Expected: 0

Indirect addressing. Cell 1 holds 5, so OUTPUT[[1]] prints what cell 5 holds, 33, which is !.

Expected: !

The cat reads, stores, prints and jumps back while the code is positive. It stops only at a 0 byte, which it prints first.

Patterns it teaches

Further

Cell-based

Write your own in Run Convert a program from Esomachine

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: esomachine.

Command line

shib run esomachine -e 'HANDS_EXPECT[]
INDEX_STATE[1, 1]
INDEX_SET[1, HANDS]
OUTPUT[1]
HANDS_JUMP[POSITIVE, 1]' --input 'cat'
shib manual esomachine

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/esomachine.js

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

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