r/cprogramming • u/North-Zone-2557 • Jan 20 '26
A BrainF*ck Compiler in C
I have tried to make a brainf*ck compiler in C using NASM. It isn't completely done but I think it works nicely. There are many things left to do to polish this completely.
10
Upvotes
5
u/RickyScarborough Jan 20 '26
Self hosting brainf*ck compiler when?
2
u/lizergsav Jan 20 '26
Nice, I love Brainfuck! Did you implement any optimizations? Combining repeated operations (e.g generating a single assembly instruction from
+++++) can be a good start.Also, how did you implement loops? A few years ago when I worked on a similar project, loops were the most challenging part.
2
u/sreekotay Jan 22 '26
If you want a comparison point - here's my "best-in-class" optimizing interpreter in C. It often outruns most compilers:
https://github.com/sreekotay/bffsree