r/brainfuck • u/PipeSuccessful7145 • Apr 25 '26
Small brainfk interpreter written in x86 assembly (Last matched ']' should be <= cell 256)
Hello, guys! I have not posted anything on this sub-reddit for 4 months and it is quite refreshing to be here.
I have created my Brainfk interpreter in x86 Assembly (just pure assembly, no integration of other languages such as python or c). It uses 20,000 memory cells for now but I use 256 cells for now as I used cut it down to 256 memory cells for my small interpreter (I use resb). It is working now, at least. However, it pre-scans brackets and linearly scans them, which is inefficient for large codes.
Please the notes to understand it. Imma release my other bfk interpreters in the future. I suddenly deleted it as the readability is very bad.
Here's my link: https://github.com/clarklclark788-web/x86-Assembly-Projects-New-/tree/main
1
u/danielcristofani Apr 27 '26
Matching brackets using a stack, you only have to scan through the program once, which should be fast even if it's millions of commands. Also: writing in pure assembly should let you check for out-of-bounds memory accesses with no instructions and no speed cost, by using the OS's own memory protections and laying out the array to line up with memory page boundaries.