GithubHelp home page GithubHelp logo

phase / bf_interpreter_jit_compiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nickdesaulniers/bf_interpreter_jit_compiler

1.0 2.0 0.0 314 KB

Teach myself about interpreters, JITs, and compilers using the Brainfuck language as the toy language

Home Page: https://nickdesaulniers.github.io/blog/2015/05/25/interpreter-compiler-jit/

License: Other

CMake 3.44% Shell 0.44% C 96.11%

bf_interpreter_jit_compiler's Introduction

#Interpreter, Compiler, JIT This repo contains three programs used in my blog post; an interpreter, a compiler, and a Just In Time (JIT) compiler for the brainfuck language. It's meant to show how similar these techniques are.

###Portability While all three are written in C, only the interpreter should be portable, even to emscripten. The compiler and JIT is highly dependant on the x64 Instruction Set Architecture (ISA), and Linux/OSX style calling convention. The assembler is made for OSX, but you can probably just link using GCC/Clang on Linux.

###Warning I take no responsibility for you running arbitrary brainfuck programs you found on the Internet through the compiler or the JIT. I would only run either in a virtual machine, just to be safe! You've been warned!

##Building ###Native

mkdir build
cd build
cmake ..
make

###Emscripten Only the interpreter is portable to JavaScript.

mkdir build
cd build
cp ../samples/* .
emcmake cmake ..
emmake make

##Running ###The Interpreter

./interpreter ../samples/hello_world.bf

or Emscripten-ized:

node interpreter.js hello_world.bf

###The Compiler

./compiler ../samples/hello_world.bf > temp.s
../assemble.sh temp.s
rm temp.s
./a.out

###The JIT

./jit ../samples/hello_world.bf

##License The code in this repo except the code in samples/ has the following license:

THE BEER-WARE LICENSE (Revision 42):
<[email protected]> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return.

Nick Desaulniers

bf_interpreter_jit_compiler's People

Contributors

nickdesaulniers avatar

Stargazers

 avatar

Watchers

 avatar  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.