Giter Site home page Giter Site logo

brainfuck-c's Introduction

Brainfuck-C

A brainfuck interpreter written in C.

What is brainfuck?

"Brainfuck is an esoteric programming language created in 1993 by Urban Mülle"

If you haven't already, give the wiki a quick read:

https://en.wikipedia.org/wiki/Brainfuck

Brainfuck is a turing complete programming language with only 8 instructions.

In addition to the instructions, you can think of Brainfuck as having three concepts:

  1. A byte array of length N. (the wiki defines it as infinite, but different implementations give it a different length)

  2. A memory pointer. *m which points to a location in the byte array.

  3. An instruction pointer. *p which points to the current instruction being read.

So when we say m, we're talking about the address of the memory pointer, and when we say *m, we're talking about the byte at the address of the pointer.

Likewise p is the address of the instruction pointer, not to be confused with the instruction itself.

The instruction set is as follows:

> - Move m forward 1.

< - Move m backward 1.

+ - Increment the byte *m.

- - Decrement the byte *m.

. - Output (print, generally) the byte *m.

, - Input a byte and set *m to it.

[ - If *m is zero, jump p to the instruction after the matching ].

] - If *m is nonzero, jump p to the instruction after the matching [.

Any characters other than the above eight are ignored.

Build

clone https://github.com/DavidHargat/Brainfuck-C

gcc main.c -o bf

Usage

./bf <filename>

Try running the helloworld program (taken from the wiki) with ./bf helloworld.bf.

Dependencies

gcc - https://gcc.gnu.org/

brainfuck-c's People

Contributors

af-inet avatar

Watchers

James Cloos avatar

Forkers

majacq

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.