esolang

Simplack

One stack of integers, nine instructions and a line number for every jump.

Saka, 2018 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 0

The idea

Saka made Simplack in 2018 to be easy to learn. A program is one instruction a line. The stack holds only integers, but any item can be read or changed by its index, counted from the bottom, so the stack works more like a row of numbered cells. An argument written $2 means the item at index 2.

Read the story

Jumps go to line numbers, counted from 0. Every line counts, the comments too.

The machine

InstructionDoes
push nPush a number
pop iRemove the item at index i
increase i n set i nAdd n to the item at index i, or set it to n
if i n goto lJump to line l if the item at index i is n
goto lJump to line l
output i a output i iPrint the item at index i as a character or as a number
input a input iPush the characters of an input line, or its number
exitStop

A line that starts with # is a comment. Running off the last line also stops the program.

Example

The truth machine.

The truth machine. On 0 it prints 0 and exits; on 1 it jumps to line 4 and prints 1 forever.

The square of the input adds the input to index 2 while index 1 counts up to it. The comment is line 0, so goto 4 lands on the first increase.

Expected: 144

The cat pushes a 0 behind the input, then prints and removes the bottom item until the 0 comes up.

Expected: cat

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Simplack

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run simplack -e 'input a
push 0
output 0 a
pop 0
if 0 0 goto 6
goto 2
exit' --input 'cat'
shib manual simplack

Source

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

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

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