Super Stack!
One stack of numbers, words for every command, and a stack you can turn like a wheel.
Orange, 2009 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Super Stack! was made in 2009 by the esolangs.org user Orange. A program is a list of keywords separated by whitespace: numbers to push, and words like add, dup and outputascii.
Read the story
The twist is that the stack is not quite a stack. cycle moves the top item to the bottom and rcycle brings the bottom one back up. With that, the stack becomes a ring you can walk around, and the specification shows how to turn any brainfuck program into Super Stack! that way.
The only control flow is if ... fi, which is really a while loop. It runs while the top value is not 0 and never pops it. Strings are pushed in reverse with a 0 under them, then printed with if outputascii fi, which stops when it reaches the 0.
The machine
One stack of integers. Words that are not keywords are ignored, so the specification writes comments as `words .
| Word | Does |
|---|---|
123 | Push a number |
add sub mul div mod | Pop two, push second op top (div and mod floored) |
and or xor nand not | Logic on 0 / not 0, pushing 1 or 0 |
random | Pop n, push a number from 0 to n-1 |
output outputascii | Pop and print as a number plus a space, or as a character |
input inputascii | Read a line as a number, or push its characters with the first on top |
pop swap dup rev | Drop, swap, duplicate, reverse the whole stack |
cycle rcycle | Move the top to the bottom, or the bottom to the top |
if ... fi | Loop while the top is not 0 (does not pop) |
quit debug | End the program, print the stack |
Popping an empty stack gives 0, since the specification is silent. Dividing by zero or printing a code outside 0 to 255 stops the program. Reading past the end of input ends it, as in the Python reference. random uses a fixed seed, so runs repeat.
Example
The numbers push the text backwards, with a 0 at the bottom and H on top.
The numbers push the text backwards, with a 0 at the bottom and H on top. The loop prints the top character each time round. When only the 0 is left, the loop ends.
Patterns it teaches
- Stack machines: one stack, with
cycleandrcyclereaching the bottom. - Turing completeness: the specification gives a fixed brainfuck-to-Super Stack! table.
Try this
- Print the numbers 1 to 10 with a loop.
- Read a line and print it back reversed.
- Hard: write the brainfuck program
+++.with the specification's conversion table and run it.
Further
See also
Stack-based
Write your own in Run Convert a program from Super Stack!
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: super-stack.
Command line
shib run super-stack -e '0 33 100 108 114 111 87 32 44 111 108 108 101 72
if outputascii fi'shib manual super-stackSource
- Module
langs/stack/ports.js- Interpreter
langs/stack/super-stack.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org