Skip to content
This repository was archived by the owner on Jul 9, 2022. It is now read-only.

Commands

LyricLy edited this page Jul 27, 2017 · 28 revisions

In these explanations, "the stack" refers to the current stack pointed to by the stack pointer.

I/O

i - Take in a byte of input as its ASCII value and push it to the stack. If there is no more input to take in, push 0.

n - Take in a space-separated portion of input as a raw number and push it to the stack.

o - Pop one number from the stack, turn it into the character with that ASCII value, and print it.

u - Pop one number from the stack, and print it.

Stack manipulation

r - Reverse the stack.

: - Duplicate the top value on the stack.

f - Flip the position of the two highest values on the stack.

! - Pop a number from the stack. If it is 0, push 1. Otherwise, push 0.

p - Pop a number from the stack.

> - Create another stack to the right of the current stack, or move to an existing one.

< - Create another stack to the left of the current stack, or move to an existing one.

y - Push the length of the stack to the stack.

Literals

" - String literals; push the ASCII value of every character after the quote to the stack until another quote is met.

0-9 - Digit literals; push the digit to the stack. Multi-digit numbers can be pushed if they are surrounded with parentheses.

Operators

+, -, *, /, % - Pop X and Y off the stack, then push Y operator X.

? - Pop X and Y off the stack, the push a random integer between Y and X.

= - Pop a number from the stack, then push 1 if the top value on the stack is equal to that number, and 0 otherwise.

G, L - Pop X and Y off the stack, then push 1 if Y operator X and 0 otherwise.

c - Pop a number from the stack, and push the number of digits in that number.

S - Pop a number from the stack, and push each of its digits individually.

Loops

[ - If the top of the stack is 0 or the stack is empty, skip the execution pointer to the corresponding ]. Otherwise, do nothing.

] - If the top of the stack is not 0 and the stack is not empty, move the execution pointer back to the corresponding [. Otherwise, do nothing.

$ - Pop a number from the stack and break out of that many layers of loops. Breaking out of a loop will place the execution pointer immediately after the end of the loop.

Backup cell

s - Save the top of the stack to the backup cell. This does not pop from the stack.

l - Take the current value of the backup cell, and push it to the stack. The backup cell will not lose its value.

Misc

; - End execution. This instruction is only required to end execution early; it is not required to add it at the end of every program.

Modified commands

Commands can be modified by placing a & symbol before them to make the instruction affect the entire stack instead of only the top value. This is the list of modifiable commands.

&+ - Push the sum of the stack. The stack will not be popped in this process.

&i - Write the entire input to the stack, in the correct order. (thus, a cat program would look like &i&o and not &ir&o

&n - Write the entire input to the stack as numbers, in the correct order. Numbers are space-separated. (thus, an input of 23 53 54 would push [54, 53, 23] to the stack, from left to right)

&o - Pop the entire stack, and print it in the correct order.

&u - Pop the entire stack, and print it, as numbers, in the correct order.

&p - Pop the entire stack.

&: - Duplicate the entire stack on top of itself.

&s - Back up the whole stack to the backup cell. The stack will not be popped in this process.

l - The command to load in a backed up stack is the same as loading in a single value.

Clone this wiki locally