Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 847 Bytes

File metadata and controls

19 lines (12 loc) · 847 Bytes

Compiling to Assembly from Scratch in Haskell

This is the repository for the compiler I built following Vladamir Keleshev's book, Compiling to Assembly from Scratch.

You can compile an ARM-32 assembly file from a given JavaScript file using run.sh:

> ./run.sh examples/js/factorial.js examples/asm/factorial.s

Then you can run that assembly code using run-asm.sh:

> ./run-asm.sh examples/asm/factorial.s factorial

The only non-Haskell pre-requisites are a gcc cross compiler for 32-bit ARM, and the qemu emulator. On Debian/Ubuntu install the packages gcc-arm-linux-gnueabihf and qemu-user. Or you can run the assembly natively on a 32-bit Raspberry Pi device.

A small example of the compiler's output can be found in the examples directory.