deutsche seite
Documents at /Partusch

Brainfucked - Documentation

The following is the documentation of the program Brainfucked - Brainfuck Compiler.

Contents of this page:
  1. Contents of the Download
  2. The Brainfuck Language
  3. The Brainfucked Compiler
    1. Usage
    2. Code Optimization
    3. Syntax Checking
    4. Compatibility
    5. Messages
  4. License Agreements
 

Contents of the Download

FileDescription
bfd.comThe Brainfucked compiler itself.
bfd.asmThe source code of Brainfucked.
src/Directory containing some examples written in Brainfuck.
src/factor.bProgram which factors an arbitrarily large positive integer.
src/hello.bPrints "Hello World!".
src/numwarp.bA number...obfuscator? Prettifier? See source.
src/prime.bCan find all primes between 0 and 255.
src/quine.bPrints its own source code.
gpl.txtThe GNU General Public License.
liesmich.txtThis documentation in German.
readme.txtThis documentation in English.

to top

 

The Brainfuck Language

Every brainfuck program has an array and a pointer, that points to the array. The array as well as the pointer can be manipulated with eight different commands:

CommandEffectSame in C
+Increase element under the pointer++*p;
- Decrease element under the pointer--*p;
>Increase pointerp++;
<Decrease pointerp--;
[Start loopwhile(*p) {
]End loop, when element is zero}
.Print ASCII code of elementputchar(*p);
,Read character and store it*p=getchar();

All other characters are ignored (and can therefore be used for annotation). All elements of the array are initialized with 0.

Further information about the language is available at the Wikipedia.

to top

 

The Brainfucked Compiler

 

Usage

The compiler must be started in the prompt of Windows or directly under MS-DOS. It is called with "bfd filename.ending". Call it for example with "bfd src/hello.b" (without the double quotes). It is important, that the name of the source code file follows the DOS style "8.3". That is, that the file name must be shorter than nine (but longer than two) characters and the file extension shorter than four characters. If that's not the case, Brainfucked will react with a "ERR: File"-error message.

to top

 

Code Optimization

Brainfucked has quite good code optimization abilities. It optimizes your brainfuck programs to use as little memory as possible, which also improves the speed of execution.

to top

 

Syntax Checking

Brainfucked checks the syntax of your programs. If it discovers an (possible) error, it prints an error message or a warning. See "Messages".

to top

 

Compatibility

Brainfucked knows two different modes to create brainfuck programs.

In standard mode the ENTER-key will result in the value 10 (LF, when it's is read by the "," command. And the value 10 (LF) will create a complete DOS/Windows-line break (CR LF), when printing it with the "." command. Therefore the standard mode is able to correctly run brainfuck programs, which are written for Unix environments. Most more complex brainfuck programs are written for these environments. Thus it's, for compatibility reasons, recommended to develop own programs according to these specifications.

When calling Brainfucked with the parameter "-n" (e.g. "bfd -n src/hello.b"), the native mode will be used by Brainfucked to compile the source.
In this mode the input read from "," is the same as the plain DOS/Windows key codes. A ENTER-key therefore results in the value 13 (CR). You also have to "manually" print 13 and 10 (CR LF) to create a correct line break. This mode is only intended for brainfuck programs, which are specifically written for DOS/Windows. These programs are, however, unable to run on many other brainfuck implementations. It is not recommended to develop own programs for this mode.

In both modes an array of 44000 cells is available to every brainfuck program and each cell has a size of one byte. Every cell is initialized with 0.

Behavior of Brainfuck commands:

CommandBehavior in standard modeBehavior in native mode
+Increase valuelike in standard mode
- Decrease valuelike in standard mode
[Start of a looplike in standard mode
]End of a looplike in standard mode
>Increase pointerlike in standard mode
<Decrease pointerlike in standard mode
.Output an ASCII-value*Output an ASCII-value*
,Read an and print the ASCII-value*Read an ASCII-value*

* see "Compatibility"!

to top

 

Messages

This is a list of all messages used by Brainfucked and their possible reasons:

MessageMeaningpossible Reason
ERR: FileError when processing filesFile not found or not in 8.3 format
ERR: LoopSerious syntax errorAt least one wrong loop like "]["
WRN: RangePossible errorMore < than > found, if not intended, it's most likely an error!
File assembledFile successfully compiledNo serious errors occurred ;-)

to top

 

License Agreements

Brainfucked is released under the terms of the GNU General Public License. See gpl.txt in the download.

to top

Have fun with Brainfucked!