OMKOV Brainfuck Compiler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jake Wakeling c06fb31155 Replace getopt with optget, Change licence to OLPE 4 weeks ago
build Replace getopt with optget, Change licence to OLPE 4 weeks ago
ext Replace getopt with optget, Change licence to OLPE 4 weeks ago
src Replace getopt with optget, Change licence to OLPE 4 weeks ago
.gitignore Replace getopt with optget, Change licence to OLPE 4 weeks ago
CHANGELOG Update getopt.h, Minor formatting improvements 2 months ago
CMakeLists.txt Replace getopt with optget, Change licence to OLPE 4 weeks ago
LICENCE Replace getopt with optget, Change licence to OLPE 4 weeks ago
README.md Replace getopt with optget, Change licence to OLPE 4 weeks ago

README.md

OBFC

Omkov Brainfuck Compiler

The Omkov Brainfuck Compiler or OBFC is an optimising Brainfuck compiler written in C, currently it can:

  • Compile Brainfuck files to x86 Assembly
  • Optimise generated Assembly

Currently OBFC only compiles to Linux x86-64 NASM Assembly.

Build Instructions

OBFC uses CMake to build.
Binaries will be located in the bin directory.

Linux Build

Run CMAKE_LINUX.sh in the build directory, or

cd build
cmake ../
make

Windows Build

Run CMAKE_WIN64.bat in the build directory.

Usage

Usage: obfc [-hv] [-o output] input

Examples:
  obfc source.bf         # Compile source.bf to default output
  obfc -o out.asm in.bf  # Compile in.bf to out.asm

Options:
  -h   Show help information
  -v   Show version information
  -o   Specify name for output file

Generated Assembly can then be assembled using NASM, for example you could run nasm -fELF64 out.asm to generate an ELF object file for a 64-bit Linux system.

Portability

OBFC uses single byte cells, and arithmetic wraps around, so - on a cell storing 0 will result in 255. OBFC currently provides 30000 cells, dynamic tape length is planned. OBFC requires brackets to be balanced, attempting to compile []] will display an error.

Optimisations

  • Combine successive >, <, + and - commands
  • Replace clear loops ([-], [+]) with SET 0
  • Replace increments following a clear loop with SET 3

Meta

Copyright (C) 2019, Jakob Wakeling
All rights reserved.
OMKOV Permissive Licence