Giter Site home page Giter Site logo

bfnasm's Introduction

BFNasm

A simple Brainfuck interpreter written in NASM. For execution using a linux x86_64 environment.

Usage

# compile using nasm 
nasm -f elf64 bfnasm.nasm -o bfnasm.o
# link object file using ld
ld bfnasm.o -o bfnasm
# run the executable with command line arguments.
./bfnasm examples/helloworld.bf

For Developers

  • The "infinite" tape is (configurably) 30k one-byte cells long, and does implement wraparound so that programs can be 30k long on either side or 20k long on one and 10k on the other without major issues. There's possibly a better way to implement the infinite tape without wraparound and still have it play nice with the language, namely doubly linked lists. However, that's left for a possible future implementation and has its own cost in performance and memory.
  • The interpreter loads the entire program at once and has a (configurable) limit of 100MB (including comments) which should be more than enough for most all bf programs. Another choice would be implementing a chunking system where the program is loaded in chunks and the interpreter only loads the next chunk when it's needed. This would be a good idea for a future implementation, but it's not a priority at the moment. Also, preprocessing might be a good idea to remove comments and compress all 8 possible instructions into 3 bits each, but again, not a priority.
  • It might be useful to add some non-cannonical instructions to the language for useful debugging, such as massive memory dumps, stepping through the program and adding breakpoints, but this might be better as a standalone debugger rather than a part of the interpreter itself.
  • Additionally, basic error handling (checking that [] match, as this is more or less the only way to make invalid programs in bf) might be a good idea.

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

bfnasm's People

Contributors

hart-venus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.