diozaka.org

abc fed ghi lkj mno rqp stu xwv yz.

Visit my Blog!

bf_*

Brainfuck is a minimalistic programming language invented by Urban Mueller. It consists of eight different commands, which are represented by single characters (see the table below) and an array with a whole lot of space.

At the beginning, every element in the array is set to 0 and the pointer points to the first location.

>
Move pointer right.
<
Move pointer left.
+
Increment the value at the pointer.
-
Decrement the value at the pointer.
[
If the value at the pointer is 0, jump to matching ].
]
If the value at the pointer is not 0, jump to matching [.
,
Read a character and save it at the current position in the buffer. (e.g. 'A'=65)
.
Print the value at the current position as an ASCII character.

All the characters not listed above are considered as comments and ignored by the interpreter/compiler.

I have written an easy-to-understand Brainfuck interpreter in C (bf_easy.c), so you can start immediately. It includes an additional debugging operator (#) to print out the decimal number that is stored at the current position in the array (instead of the corresponding ASCII character). I also wrote a tiny and obfuscated version (344 bytes, bf_tiny.c), just because I can. [*]

Download

[*] The tiny and obfuscated version is, admittedly, not very flexible and limited to quite small Brainfuck programs consisting of less than 8000 characters, which use only the first 2000 elements of the data array.

Copyright (c) 2005-2010 diozaka / Erik Scharwaechter <erik@diozaka.org>