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.
Přemysl Janouch a4390d38b5
Fix interpreter portability
2 years ago
..
Makefile Fix interpreter portability 1 year ago
README.adoc Update READMEs 2 years ago
bf-faster-loops.c Initial commit 2 years ago
bf-jit-opt.c Initial commit 2 years ago
bf-jit-unsafe-opt.c Initial commit 2 years ago
bf-jit-unsafe.c Initial commit 2 years ago
bf-jit.c Initial commit 2 years ago
bf-optimizing.c Initial commit 2 years ago
bf.c Initial commit 2 years ago

README.adoc

This directory contains several Brainfuck interpreters in various states of sophistication, from the simplest approach to an optimizing JIT compiler:

  • bf.c is the stupidest one and the oldest by far

  • bf-faster-loops.c precomputes loop jumps

  • bf-optimizing.c improves on that by changing [-]+ loops into assignments

  • bf-jit.c adds JIT compilation for Intel x86-64

  • bf-jit-opt.c tries a bit harder to avoid looping on the current value

  • bf-jit-unsafe.c abolishes all boundary checks when moving across the tape

  • bf-jit-unsafe-opt.c makes use of immediate offsets to modify values

I recommend using a tool such as meld to view the differences.

Just run make in this directory to have them all built, and append CPPFLAGS=-DDEBUG to get dumps of the IR for the more sophisticated JITs. The interpreters take the program on standard input and read characters directly from the terminal device, so to run a simple cat-like program, you can do:

$ echo ',[.,]' | ./bf