Brainfuck interpreter in AT&T syntax x86 Assembly. Optimization strategies were gleaned from Mats Linander's blog post. The program was created as a part of the Computer Organisation course at TU Delft.
- Clone this repo in a new directory.
git clone https://github.com/totomanov/bf-interp.git
- Assemble the program with GCC.
gcc -no-pie -o brainfuck brainfuck.s
- Create a file with brainfuck code. Example
helloworld.b
:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
- Execute the binary with the file as an argument.
./brainfuck helloworld.b
- Pass the
-g
flag to GCC.
gcc -g -no-pie -o brainfuck brainfuck.s
- Start the debugger.
gdb ./brainfuck
To benchmark the interpreter, you can run common benchamrking programs in brainfuck such as hanoi.b
or mandelbrot.b
.
They can be found at this website which also shows the intended output.
Measuring the execution time of the interpreter is easily done with the GNU time utility. Simply prepend the execution call with time
.
time ./brainfuck mandelbrot.b