bfasm is a brainfuck to assembly converter written in Rust.
Please note that the project currently only generates Windows x86-64 assembly in Intel syntax!
You can try one of the Brainfuck programs supplied in tests or one of your own.
$ cargo run filename.bf
Which will generate filename.asm
.
Using nasm
and the Visual Studio Developer Command Prompt:
$ nasm -fwin64 filename.asm
$ link filename.obj msvcrt.lib /LARGEADDRESSAWARE:NO
$ ./filename
- optimize generated assembly (e.g. multiple
inc
s to oneadd
etc.) - flag to generate 32 bit Assembly?
- flag to generate Assembly in AT&T Syntax
- flag to generate Assembly for Linux
- fix
/LARGEADDRESSAWARE:NO
when linking
I've only been getting into assembly for the past days, therefore the generated assembly won't be the most optimized or "sane". But that is just an obstacle that can be tackled in the future.
The generated assembly calls to _getch
and putchar
from libc
as there are no proper syscalls for Windows like on Linux.
I've made a Brainfuck Debugger that could be used to debug Brainfuck programs before converting them to assembly.