Extentions

BrainFuzz add the following operations to the brainfuck language.


Op Function
(
If cell at pointer is 0 jump to the corresponding ')'
)
Jump to point of '('
!
Inverts if and while conditions, also inputs a string into cells if used before ' " '
;
Reads a number from input and puts it's numerical value in cell at pointer
:
Outputs the current cells value as a number NOT ascii e.g. cell is 65, outputs 65 not 'A'
"
Outputs everything up until corresponding ' " '
^
Saves current cells value in a temp register
=
Current cell becomes the value in the temp register

IF statements: '()'

If statements work the same as looping in a normal brainfuck program however there is no jumping back to the opening bracket. When the '(' is preceeded by '!', the condition is inverted i.e. jumps if value is not 0. A standard if{}else{} is as simple as ("true")!("false").

The ! Operator

The ! operator has two functions. If it is used before a ( or [ it inverts the condition. So if you wanted to loop while a cell was equal to zero, you'd use ![]. The other function is to load a string into the tape from the source code. For example: !"Hello!"<[<]>[.>] prints "Hello!".

To do this it reads the first character into the current cell then moves the pointer to the right and repeats until it encounters another ". This leaves the pointer on the cell AFTER the end of the string. This function is only really useful if you want to manipulate the string. Otherwise you can just use " " to print a string.

Additional Input and Output

Brainfuzz allows you to output the numerical value thats stored in a cell without having to convert it into ascii first. You can also do the opposite and read in a numerical value instead of the ascii value.

The Temp Register

Brainfuzz introduces a new register that can store one cell's value ising the ^ operator and then using = can overwrite the current cell. If you have used brainfuck before you know how tedious it can be to copy the contents of a cell to another one.