Useful brainfuck
Useful brainfuck is a brainfuck-derivative created by User:Evylah which aims to be useful. It still is brainfuck at its core, but adds a handful miscellaneous instructions to aid with programming.
Additions
Along with new instructions, Useful brainfuck adds a new accumulator. This is just another cell, but can be accessed from anywhere in the program. The accumulator is a 8-bit wrapping number and initializes to 0.
Wrapping mode can be toggled with '
and is on by default. When off, each cell and the accumulator can hold any integer, not just numbers from 0-255.
Instruction set
Input is taken in and stored mod 256 if wrapping mode is on.
Vanilla brainfuck
op | description |
---|---|
> <
|
Select the cell one to the right or left. |
+ -
|
Increment and decrement the current cell by one. |
[
|
Jump to the corresponding ] if the current cell is zero.
|
]
|
Jump to the corresponding [ if the current cell is not zero.
|
, .
|
Input and output the current cell as a Unicode character. |
Useful brainfuck
op | description |
---|---|
(
|
Set the accumulator's value to the current cell. |
)
|
Set the current cell's value to the value of the accumulator. |
0
|
Set the accumulator to 0. |
?
|
Set the accumulator to a random number 0 through 255 inclusive. |
{ }
|
Move the memory tape pointer left/right the accumulator's value times. |
i d
|
Increment/decrement the accumulator by 1. |
I D
|
Increment/decrement the accumulator by 10. |
* /
|
Double and halve the accumulator, rounded to the nearest integer. |
a
|
Accumulator = Accumulator + Value of current cell |
A
|
Value of current cell = Value of current cell + Accumulator |
; :
|
Input and output the current cell as a number. |
'
|
Toggles wrapping mode. |
Examples
A + B problem
Using accumulator:
;(;A:
No accumulator (also works with Brainfuck+2)
;>;<[>+<-]>:
Turing-completeness
Since any brainfuck program can run in Useful brainfuck, Useful brainfuck is Turing-complete.