Brainstuck

From Esolang
Jump to: navigation, search

Brainstuck is a variation of Brainfuck, with a stack instead of a tape. The commands are:

  • "+" 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 onto 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

Echo:

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