This directory contains several Brainfuck interpreters in various states of sophistication, from the simplest approach to an optimizing JIT compiler:
bf.cis the stupidest one and the oldest by far
bf-faster-loops.cprecomputes loop jumps
bf-optimizing.cimproves on that by changing
[-]+loops into assignments
bf-jit.cadds JIT compilation for Intel x86-64
bf-jit-opt.ctries a bit harder to avoid looping on the current value
bf-jit-unsafe.cabolishes all boundary checks when moving across the tape
bf-jit-unsafe-opt.cmakes use of immediate offsets to modify values
I recommend using a tool such as meld to view the differences.
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
you can do:
$ echo ',[.,]' | ./bf