Skip to content

MarceliJankowski/brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck interpreter written in x86-64 AT&T ASM

Description

As the header says, this is a brainfuck interpreter written in x86-64 AT&T assembly.
It adheres to this specification.

The "neat" thing about it, is that it's written without any external libraries (no libc).
Everything's done with good old syscalls!

Table of Contents

Installation

This project uses GNU make build system, so you're gonna need it.
All build dependencies are listed in this Makefile.

Here are installation commands:

$ git clone https://github.com/MarceliJankowski/brainfuck.git
$ cd ./brainfuck
$ make

Usage

After successful installation, you just need to run brainfuck executable with the input source path:

$ ./brainfuck ./examples/helloWorld.bf

Note: If you wanna play around, examples directory contains various ready-to-run brainfuck programs.

Disclaimer

This is my first-ever assembly project (which upon further inspection becomes painfully obvious).
Code isn't of the highest quality, and there are MANY things that could be improved upon.

One of which is test coverage.
I didn't bother writing a single test case for this entire thing (Oops!).
Suspiciously, I haven't encountered any bugs so far...
This only assures me, that the ones that are hiding are the nasty ones (beware!).

The other thing that in a real setting wouldn't fly, is the lack of external dependencies.
While it was great to write my own data structures and utilities for educational value, it's far from recommended.
Modern implementations have hundreds of sophisticated optimizations, there's really no point in competing with them.
Here, it's not that big of a deal, as it's just an educational endeavor.
But in a real project, we wouldn't reinvent the wheel (especially that poorly), we would harness its power!

Motivation

Ever since CLA I've been intrigued with interpreters and compilers.

Now, when I started college I've got plenty of spare time that I can spend on exploring this fascinating topic.
I decided that assembler would be a good starting point (and boy was I right!).
This interpreter taught me a lot and was a great starting point for my upcoming projects.

Speaking of which, I plan to write another interpreter for a made-up language.
Then, once that's done I'll submerge myself in the mesmerizing sea of Compilers: Principles, Techniques, and Tools.
If it all goes well, I'll emerge victorious, with compiler abomination of my own craftsmanship!

Overall it was a great project for solidifying my assembly knowledge.
I even managed to pass several classes at college with this thing (haha)!

I would definitely recommend building something similar if you're an ASM beginner like me.
Even such simple thing as brainfuck interpreter has a surprising amount of complexity hidden underneath.

Resources

My whole assembly knowledge (meager as it is) comes from: Learn to Program with Assembly and Programming from the ground up, works written by Jonathan Barlett.

Both of these books are just plain amazing and I can't praise them enough.
They're great resources for anybody wanting to dip their toes in this mysterious assembly world.

Jonathan writes in a very approachable and straightforward way, making it easy to follow along and just learn.
Going through these books was a great deal of pleasure and a solid dose of ASM knowledge.
Each day I eagerly anticipated the moment where I could just sit down, and sink it in.

This project also served as my introduction to GNU make build system.
I gotta say, that it's an interesting piece of software (although quite convoluted...).

Managing Projects with GNU Make by Robert Mecklenburg helped me wrap my head around this mess.
Another great resource that I can't recommend enough (it would've been hard without it).

I'm really grateful for people like Jonathan Barlett and Robert Mecklenburg.
People that give back to the community, and raise new programmer generations.
I'm hopeful that one day, I'll be able to do the same.

License

Distributed under the MIT License.
You are free to use, modify, and distribute the source code as long as you include the original copyright notice.

About

Brainfuck interpreter written in x86-64 AT&T assembly

Resources

License

Stars

Watchers

Forks

Packages

No packages published