https://github.com/micahcantor/comp-to-assembly-from-scratch-hs
A toy JS to ARM assembly compiler, in Haskell
https://github.com/micahcantor/comp-to-assembly-from-scratch-hs
Last synced: about 2 months ago
JSON representation
A toy JS to ARM assembly compiler, in Haskell
- Host: GitHub
- URL: https://github.com/micahcantor/comp-to-assembly-from-scratch-hs
- Owner: micahcantor
- Created: 2022-04-30T06:45:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-30T04:37:28.000Z (almost 3 years ago)
- Last Synced: 2025-01-13T18:45:59.083Z (3 months ago)
- Language: Haskell
- Homepage:
- Size: 177 KB
- Stars: 16
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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*](http://keleshev.com/compiling-to-assembly-from-scratch).
You can compile an ARM-32 assembly file from a given JavaScript file using `run.sh`:
```shell
> ./run.sh examples/js/factorial.js examples/asm/factorial.s
```Then you can run that assembly code using `run-asm.sh`:
```shell
> ./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.