2

Brainfuck implementation in x86_64 assembly

 3 years ago
source link: https://github.com/birb007/bfasm/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Brainfuck implementation in x86_64 assembly

This is an implementation of the Brainfuck language. Brainfuck is an esolang which is closely resembles a Turing machine (with the addition of bulit-in conditional expressions). The interpreter is implemented using a switch table (jump tables were less performant) and a 32 byte IO buffer to improve performance.

Further development would involve:

  • Code alignment improvement
  • Ordering of operations to reduce port load

Installation and build instructions:

$ git clone https://github.com/birb007/bfasm.git
$ cd bfasm
$ make

A bfasm executable should then be present in the main repository directory. To use the interpreter, specify a sourcefile in the command line arguments.

usage: ./bfasm <filename>

All testing code was found online and is not my own work. A demonstration of the interpreter using Daniel B. Cristofani's Fibonacci implementation.

example usage

Performance

bfasm executed 10,521,107,970 Brainfuck operations in 67.27 seconds (156,424,442/s).

sudo perf stat -a -B -o perf_report ./bfasm tests/mandelbrot.bf

Note: the elapsed time includes process initialisation and destruction.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK