(--- This is the original documentation of the Brainfuck distribution ---)


                          Cat's-Eye Technologies 
                                      
                                 Brainf***
                                      
       An 8-instruction Turing-complete computer programming language
                                      
          --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---
                                      
                 Portable C source code and .b source files
                                      
   Brainf*** is a minimal language developed by Urban Mueller. While it
   only has a total of eight instructions, it can solve any solvable
   mathematical problem. The remainder of this page is a copy of the
   original readme file. Unfortunately, the original 680x0 assembler code
   is now lost.
   
   Yes, the language name contains a dirty word. For the sake of taste we
   have decided to only imply what that word actually is.
   
This archive contains the following programs:

*bfc          The compiler for the 'brainf***' language (240 bytes!)
*bfc.asm      Source for the compiler
*bfi          The interpreter for the 'brainf***' language
 bfi.c        Source for the interpreter (portable)
 src/         Some example programs in 'brainf***'
 src/atoi.b   Reads a number from stdin
 src/div10.b  Divides the number under the pointer by 10
 src/hello.b  The ubiquitous "Hello World!"
 src/mul10.b  Multiplies the number under the pointer by 10
 src/prime.b  Computes the primes up the a variable limit
 src/varia.b  Small program elements like SWAP, DUP etc.

[ed. note: files marked with an asterisk * could not be recovered. cap]

WHATS NEW
=========

Yes, I squeezed another ridiculous 56 bytes out of the compiler. They have
their price, though: The new compiler requires OS 2.0, operates on a byte
array instead of longwords, and generates executables that are always 64K
in size. Apart from that the language hasn't changed. Again:
***  OS 2.0 *required* for the compiler and the compiled programs  ***
The interpreter works fine under any OS version. And yes, thanks to Chris
Schneider for his ideas how to make the compiler shorter.

[ed. note: Amiga OS version 2.0, not to be confused with OS/2. cap]

THE LANGUAGE
============

The language 'brainf***' knows the following commands:

 Cmd  Effect                                 Equivalent in C
 ---  ------                                 ---------------
 +    Increases element under pointer        array[p]++;
 -    Decrases element under pointer         array[p]--;
 >    Increases pointer                      p++;
 <    Decreases pointer                      p--;
 [    Starts loop, counter under pointer     while(array[p]) {
 ]    Indicates end of loop                  }
 .    Outputs ASCII code under pointer       putchar(array[p]);
 ,    Reads char and stores ASCII under ptr  array[p]=getchar();

All other characters are ignored. The 30000 array elements and p are being
initialized to zero at the beginning.  Now while this seems to be a pretty
useless language, it can be proven that it can compute every solvable
mathematical problem (if we ignore the array size limit and the executable
size limit).


THE COMPILER
============

The compiler does not check for balanced brackets; they better be. It reads
the source from stdin and writes the executable to stdout. Note that the
executable is always 65536 bytes long, and usually won't be executable if
brackets aren't balanced. OS 2.0 required for the compiler and the compiled
program.


THE INTERPRETER
===============

For debugging, there's also an interpreter. It expects the name of the
program to  interpret on the command line and accepts an additional command:
Whenever a '#' is met in the source and a second argument was passwd to
the interpreter, the first few elements of the array are written to stdout
as numbers


   Enjoy

     -Urban Mueller
