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.

README.adoc 1002B

2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920
  1. This directory contains several Brainfuck interpreters in various states of
  2. sophistication, from the simplest approach to an optimizing JIT compiler:
  3. * `bf.c` is the stupidest one and the oldest by far
  4. * `bf-faster-loops.c` precomputes loop jumps
  5. * `bf-optimizing.c` improves on that by changing `[-]+` loops into assignments
  6. * `bf-jit.c` adds JIT compilation for Intel x86-64
  7. * `bf-jit-opt.c` tries a bit harder to avoid looping on the current value
  8. * `bf-jit-unsafe.c` abolishes all boundary checks when moving across the tape
  9. * `bf-jit-unsafe-opt.c` makes use of immediate offsets to modify values
  10. I recommend using a tool such as _meld_ to view the differences.
  11. Just run `make` in this directory to have them all built, and append
  12. `CPPFLAGS=-DDEBUG` to get dumps of the IR for the more sophisticated JITs.
  13. The interpreters take the program on standard input and read characters
  14. directly from the terminal device, so to run a simple `cat`-like program,
  15. you can do:
  16. $ echo ',[.,]' | ./bf