Giter Club home page Giter Club logo

compiling-to-assembly-from-scratch's Introduction

Compiling to Assembly from Scratch

This repository contains source code from the book Compiling to Assembly from Scratch, plus ports to other langauges (currently Python, OCaml, and Rust)

Structure

  • part-1 folder contains the baseline compiler from Part I of the book.
  • part-2 folder contains the extended compiler from Part II of the book.
  • contrib folder is for various other versions of the compiler. Contributions are welcome.

Running the code

The book's compilers are wirtten in TypeScript, so you need to install the TypeScript compiler. TypeScript compiles to JavaScript, so you need Node to run it in a non-browser environment (however, it works in browser too).

On Rasperry Pi

Install Node and TypeScript:

$ sudo apt-get install npm
$ sudo npm install -g typescript

Now you've got everything necessary to run the compiler's test suite. No emulation or cross-assembling necessary.

$ make CC=gcc RUN=''

On x86-64 Linux

This assumes apt-get package manager.

Install TypeScript (and Node, as a dependency):

$ sudo apt-get install npm
$ sudo npm install -g typescript

Install GCC toolchain that targets 32-bit ARM:

$ sudo apt-get install gcc-arm-linux-gnueabihf

Install QEMU emulator:

$ sudo apt-get install qemu-user-static

Run baseline compiler's test suite:

$ make CC='arm-linux-gnueabihf-gcc -static' RUN='qemu-arm-static'

In the browser

Minimal browser playground is available as well.

cd part-2
make ../docs/build.js
open ../docs/index.html

Contribution

You are welcome to contribute your version of the book's compiler. Make a pull request into the contrib directory.

compiling-to-assembly-from-scratch's People

Contributors

agentcooper avatar brendanzab avatar jaypowers avatar keleshev 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.