Stacky
Stacky is a stack-based esoteric language created by User:Braden inspired by BFVM2, befunge, dc, and forth, among others. It has a 4096-byte stack and a single register to store temporary values in.
Programs are stored in a peculiar encoding: the code is base64'd, then each base64 chunk is reversed, then the whole program is rot13'd. This is done purely to make it annoying to write programs in Stacky.
List of operators
As described in the specification:
pv push v to stack. v can be a number or a string delimited by surrounding '. values are modulo 256 and strings are pushed character-by-character i push character from stdin to stack o pop from stack and print as character . pop from stack and print as characters until a zero is reached if empty stack is popped, interpreter will quit with error message "IM DED XP" this applies to all instructions that pop from the stack n pop from stack and print as number. In hexadecimal. s pop from stack and store in register l push value in register to stack d duplicate top of stack empty stack = crash w swap top of stack with value under it stack length < 2 = crash + pop two values from stack and add, push result to stack - pop two values from stack and subtract first popped value from second popped value same semantics as + ^v pop from stack and jump forward v instructions if value is zero, otherwise move to next instruction if jumping out of bounds, interpreter will quit with error message "IM LOST D:" #v jump backward v instructions unconditionally same semantics as ^ e end the program (required)
Examples
Hello World program:
p0p10p'dlroW olleH' .e
Output:
Hello World
Truth Machine:
idp'0'-^5ddo#4oe
Output:
0 0
Output:
1 1111111111111111111111...
Infinite smiley faces:
p0^10eeeeeeeeep'):'oo#3
This will push 0 to the stack, jump 10 instructions forward, skipping the 9 e
instructions, then push )
and :
to the stack and print both of them, then jump 3 instructions back, entering an infinite loop of printing :)
without a newline
External Links
- Language specification: https://gitlab.com/bradenbest/stacky/-/blob/main/language-spec.md
- Rust implementation (WIP): https://gitlab.com/AuroransSolis/stacky-interpreter