esolang

ESOPUNK

An EXA from the game EXAPUNKS, let out of its network and given a keyboard and a screen.

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

Tested with 5 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hi

The idea

In Zachtronics' puzzle game EXAPUNKS, the player programs small robots called EXAs in a terse assembly language. ESOPUNK, by Blacksilver, takes that language out of the game. There is no network to move through, so stdin, stdout and stderr appear as the hardware registers #STDI, #STDO and #STDE.

Read the story

An EXA has two registers. X holds anything, and T is where tests put their answer, 1 or 0, for the conditional jumps to read. In the game numbers are clamped to four digits; in pyESOPUNK, the reference, they are not.

The machine

CodeDoes
COPY a rCopy a number or register into a register
ADDI a b r SUBI MULI DIVI MODIArithmetic into r
SWIZ a b rRearrange the digits of a as the digits of b say
TEST a = b / a < b / a > bSet T to 1 or 0
MARK nameA label
JUMP name TJMP name FJMP nameJump always, if T is not 0, if T is 0
HALT NOOP NOTE textStop, wait, comment

Reading #STDI takes one byte of input; writing #STDO prints one. At the end of the input #STDI gives -1. The game's files, links, messages between EXAs and replication are not part of this implementation; pyESOPUNK does not have files or REPL either.

Example

The second program uses T as a scratch register for the digit and then overwrites it with the test, which…
Expected: 12345
Expected: meow

The second program uses T as a scratch register for the digit and then overwrites it with the test, which is what decides the jump. The third is the cat from esolangs.org.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from ESOPUNK

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run esopunk -e 'COPY 79 #STDO
COPY 75 #STDO'
shib manual esopunk

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/esopunk.js

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

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