Brainstuck

From Esolang
Jump to navigation Jump to search

Brainstuck is a variation of Brainfuck, with a stack instead of a tape.

Commands

The commands are:

Token Command
+ Increments the top value of the stack.
- Decrements the top value of the stack.
. Pops the top value of the stack, and outputs it.
, Pushes a byte from stdin on the stack.
0 Pushes 0 onto the stack.
: Pops the top value of the stack, and pushes the value at a depth of that depth into the stack onto the stack.
[ Pops the top value of the stack, and if that value is 0, jumps to the opcode after the corresponding ].
] Jumps to the corresponding [.

Examples

Infinite cat program

0+[,0:.+]

Forth codes

It is possible to convert into Forth codes by:

+  1+ 255 AND
-  1- 255 AND
0  0
:  PICK
,  KEY
.  EMIT
[  BEGIN WHILE
]  REPEAT

Some other commands in Forth can be also using the Brainstuck codes:

DUP              0:
OVER             0+:
THEN             0]
0 *              0:[-0:]
DROP             [0:[-0:]]

External resources