Giter VIP home page Giter VIP logo

bf-ext's Introduction

bf-ext

A brainfuck interpreter with extended features, such as support for syscalls.

Why?

Traditional Brainfuck is touted as "Turing complete," meaning that you can technically do anything in the language. However, in order to do things like reading files or executing other programs, you would need an OS built with some sort of brainfuck interop or some shit. Since aint nobody got time for that, I decided I would extend the language slightly to make it compatible with existing OS syscalls (only on 64 bit linux for now).

What's different?

There are two new tokens that make calling syscalls possible.

Syscall Operator: $

The $ operator copies 48 bytes starting at the current pointer and sends them as arguments to the C stdlib syscall() function. It then replaces the next 8 bytes starting at the current pointer with the return value of the syscall.

Dereference Operator: @

Since any pointer passed to a syscall needs an actual memory pointer and not an index in the array, we need a way to get the memory address of an index the programmer would know. When encountered, the interpreter takes the next 4 bytes starting at the current pointer and indexes into the memory array with it as if it were an integer. It then gets a pointer to that index in the memory array and stores it as 8 bytes starting at the current memory pointer.

Build

Just compile in your favorite C compiler

gcc -o bf-ext bf-ext.c

Run

Just supply the name of the bf file to interpret.

./bf-ext examples/hello.bf
Hello world!

bf-ext's People

Contributors

spicydll avatar

Stargazers

Jon-Michael avatar

Watchers

 avatar

bf-ext's Issues

What is this cmake error

CMake Error: The source directory "/home/lucas/wrk/bf-ext" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

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.