This archive contains the following programs: bfc The compiler for the 'brainfuck' language (296 bytes!) bfc.asm Source for the compiler bfi The interpreter for the 'brainfuck' language bfi.c Source for the interpreter src/ Some example programs in 'brainfuck' 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. THE LANGUAGE ============ The language 'brainfuck' 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 array elements and p are 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 4096 bytes long unless you change a constant in the compiler source, which you'll need to do for larger programs. 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