StackSwap
Jump to navigation
Jump to search
StackSwap is an esolang by User:Fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff designed around function calls.
Syntax
A StackSwap program is a series of function definitions, which start with the function name, then a colon, and finally a list of function calls.
Semantics
StackSwap contains two stacks, one of which is selected to be the current stack, as well as an instruction pointer. When a function is called the function calling it is placed onto the current stack and control moves to the called function.
Built-in methods
§
: Swap the two control stacks. Note that this method returns to the function it was called from normally.out1
: Send a 1 to the little-endian output buffer. When the buffer has eight bits, output that byte to stdout.out0
: Send a 0 to the little-endian output buffer. When the buffer has eight bits, output that byte to stdout.read
: Remove a bit from the front of the little-endian input buffer and execute§
if it is a 1. If the buffer is empty, input a byte to the buffer.
Examples
Hello, World!
a: out1 out0 out0 out1 out0 out0 out0 out1 out1 out0 out0 out1 out0 out1 out1 out1 out0 out1 out1 b: out0 out0 out1 out1 out0 out1 out1 out0 out0 out1 out1 out0 out1 out1 out1 out1 out1 out0 out1 c: out1 out0 out0 out1 out0 out0 out0 out0 out0 out1 out0 out1 out0 out1 out1 out1 out1 out1 out0 d: out1 out1 out1 out1 out1 out1 out1 out0 out0 out1 out0 out1 out1 out0 out1 out1 out0 out0 out1 e: out1 out0 out0 out1 out0 out0 out1 out0 out0 out0 out0 out1 main: a b c d e
Truth-machine
waste: read read read read read read read next: read § a zero: § next out0 out0 out1 out1 out0 out0 out0 out0 main: waste next one one: out0 out0 out1 out1 out0 out0 out0 out1 one