HomeForumRiddle ToolsWallpapersLinks
Brainfuck
 
Brainfuck or brainf*ck is an Eight-Instruction Turing-Complete Programming Language based on the P prime prime (P") programming language, and was created by Urban Müller in 1993. His goal was to create a Turing-complete language for which he could write the smallest compiler ever, for the Amiga OS 2.0. His compiler was 240 bytes in size, though he improved upon this later.

A Brainfuck program has an implicit byte pointer, called "the pointer", which is free to move around within an array of 30000 bytes, initially all set to zero. The pointer itself is initialized to point to the beginning of this array.

The Brainfuck programming language consists of eight commands, each of which is represented as a single character.

For more detailed information please read the Wikipedia page on the subject.

Example

Enter the following sequence - it should translate as 'Purple Hell!'

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++++++++++. >+++++++++++++++++.---.--.----.-------.>++.<<--------.>.+++++++..>+.>.

 
Character Action
>
Increment the pointer.
<
Decrement the pointer.
+
Increment the byte at the pointer.
-
Decrement the byte at the pointer.
.
Output the byte at the pointer.
,
Input a byte and store it in the byte at the pointer.
[
Jump forward past the matching ] if the byte at the pointer is zero.
]
Jump backward to the matching [ unless the byte at the pointer is zero.
 
The semantics of the Brainfuck commands can also be succinctly expressed in terms of C, as follows (assuming that 'p' has been previously defined as a char*)
 
Character Becomes
++p;
--p;
++*p;
--*p;
putchar(*p);
*p = getchar();
while (*p) {
}
 
Brainfuck Interpreter
 
 

Brainfuck Interpreter
Debug mode:
Large variables:
Prompt for input:
Alert when finished:

Input Brainfuck Code:

 
Output Text:



Script courtesy of  Mcoffey at Justice Loyola


back to top
 
 
Sources:
Muppetlabs - Brainfuck
Justice Loyola - Mcoffey brainfuck interpreter