Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
EBFC(1) FreeBSD General Commands Manual EBFC(1)

ebfc - ELF Brainfuck compiler

ebfc [-lxcszhv] [-f FUNCTION] [-o FILE] [-i FILE] SRCFILE

ebfc is a compiler for the Brainfuck programming language, creating 32-bit ELF files targeted for the Linux platform running under an Intel x86 architecture.
ebfc can create standalone executables, shared libraries, or object files, and the object file can itself be targeted for a standalone executable or a shared library, as well as a simple module.

The following options control how the source file is compiled. It is assumed here that the name of the source file is foo.b.
Compile the source code into a standalone executable file, named foo.
Compile the source code into a function, named foo(), in a shared library file, named
Compile the source code into a function, named foo(), in an object file, named foo.o.
Compile the source code into an object file, named foo.o, that can then be linked into a standalone executable.
Compile the source code into a function, named foo(), in an object file, named foo.o, that can then be linked into a shared library.
If the source filename lacks a .b suffix, then the entire filename will be used when creating the name of the target file and function. (In the case of -x, the name of the target file will be a.out instead.)

Use FUNCTION as the name of the function to contain the compiled program. (This option is not generally useful when the final target is a standalone executable.)
Use FILE as the target filename.
Use FILE as the name of the source file to place in the target file. This option is only meaningful if the target is an object file, and if the -s option is not used.
Suppress inclusion of unnecessary data in the target file. By default, ebfc includes a .comment section in object and library files, and includes the source filename in the .symtab section. These items will be removed from the output when this option is used.
Display help and exit.
Display version number and exit.
Read the source file in compressed Brainfuck format.

When calling a compiled Brainfuck program from within a C program, the C prototype for the Brainfuck function should have the form:

extern void foo(void);

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.
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 to the matching ] if the byte at the pointer is zero.
Jump to the matching [.
Any other characters in the source code are treated as comments or whitespace, and ignored.
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*):
becomes  ++p;
becomes  --p;
becomes  putchar(*p);
becomes  *p = getchar();
becomes  while (*p) {
becomes  }

Chris Pressey introduced a compressed format for storing and transmitting Brainfuck programs, which ebfc can read natively by using the -z option.
In compressed Brainfuck, the eight commands are encoded in three bits as follows:
Each byte in a compressed Brainfuck file can contain two or more commands. The top two bits select between one of four possible readings of the lower six bits, as follows:
Encoding    Bits
singleton   00 abc abc
pair        00 abc def
abc followed by def
triplet     10 ab cd ef
0ab then 0cd then 0ef
repetition  01 abc def
def repeated 2 + abc times (2-9)
repetition  01 abcd ef
0ef repeated 2 + abcd times (2-17)

The compiler will issue an error message, and the compilation will fail, if the program contains unbalanced bracket commands, or if the level of nested brackets exceeds the compiler's maximum capacity (which is arbitrarily set at 256).
The program's behavior is subsequently undefined if the pointer is moved outside of the 30000-byte array.

Copyright © 1999 Brian Raiter <>.
License GPLv2+: GNU GPL version 2 or later. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
July 1999 ELF kickers 2.0

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.