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 2.2KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. bfc
  2. ===
  3. 'bfc' is a small, fast, self-contained, optimizing Brainfuck compiler for *nix
  4. on Intel x86-64.
  5. Also included are several interpreters in various states of sophistication that
  6. document my progress as I was writing this, from the simplest approach to an
  7. optimizing JIT compiler.
  8. It's pretty easy to retarget the compiler, it just means redoing half the work.
  9. Thanks to the unified ABI, adding support for another flavour of *nix only means
  10. changing the syscall numbers. The compiler itself is platform agnostic.
  11. Building
  12. --------
  13. Build dependencies: a C99 compiler +
  14. Runtime dependencies: Linux or OpenBSD
  15. $ git clone
  16. $ cd bfc
  17. $ make
  18. To obtain dumps of the intermediate representation, compile with `-DDEBUG`:
  19. $ make CPPFLAGS=-DDEBUG
  20. Usage
  21. -----
  22. $ ./bfc-amd64-linux [INPUT-FILE] [OUTPUT-FILE]
  23. $ ./bfc-amd64-openbsd [INPUT-FILE] [OUTPUT-FILE]
  24. When no input file is specified, standard input is used. Similarly, the default
  25. output filename is `a.out`. After the compilation, the resulting file can be
  26. run on the target platform.
  27. gdb
  28. ---
  29. You may have noticed the `gdb-experiment.go` file. It is a non-optimizing
  30. version of the compiler targeting Linux only that adds DWARF debugging
  31. information mapping code locations onto lines in the `ir-dump.txt` byproduct
  32. output file. It's been rewritten in Go since managing all those binary buffers
  33. required to build the symbol table proved to be too painful in C.
  34. $ go run gdb-experiment.go [INPUT-FILE] [OUTPUT-FILE]
  35. Use `break *0x4000b7` to get a breakpoint at the first Brainfuck instruction.
  36. Contributing and Support
  37. ------------------------
  38. Use this project's GitHub to report any bugs, request features, or submit pull
  39. requests. If you want to discuss this project, or maybe just hang out with
  40. the developer, feel free to join me at irc://, channel #dev.
  41. License
  42. -------
  43. 'bfc' is written by Přemysl Janouch <>.
  44. You may use the software under the terms of the ISC license, the text of which
  45. is included within the package, or, at your option, you may relicense the work
  46. under the MIT or the Modified BSD License, as listed at the following site: