GSP
Quick Navigator

Search Site

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

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  EBFC (1)

NAME

ebfc - ELF Brainfuck compiler

CONTENTS

Synopsis
Description
Compilation Options
Other Options
Linking
The Brainfuck Programming Language
Compressed Brainfuck
Errors
Copyright

SYNOPSIS

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

DESCRIPTION

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.

COMPILATION OPTIONS

The following options control how the source file is compiled. It is assumed here that the name of the source file is foo.b.
-x Compile the source code into a standalone executable file, named foo.
-l Compile the source code into a function, named foo(), in a shared library file, named libfoo.so.
-c Compile the source code into a function, named foo(), in an object file, named foo.o.
-xc Compile the source code into an object file, named foo.o, that can then be linked into a standalone executable.
-lc 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.)

OTHER OPTIONS

-f FUNCTION
  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.)
-o FILE Use FILE as the target filename.
-i FILE 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.
-s 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.
-h Display help and exit.
-v Display version number and exit.
-z Read the source file in compressed Brainfuck format.

LINKING

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);

THE BRAINFUCK PROGRAMMING LANGUAGE

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 }

COMPRESSED BRAINFUCK

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:
+ 000
- 001
< 010
> 011
[ 100
] 101
, 110
. 111
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 Translation
singleton 00 abc 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)

ERRORS

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

Copyright © 1999 Brian Raiter <breadbox@muppetlabs.com>.

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.

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


ELF kickers 2.0 EBFC (1) July 1999

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