Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keleshev/compiling-to-assembly-from-scratch
Source code for the book Compiling to Assembly from Scratch https://keleshev.com/cas
https://github.com/keleshev/compiling-to-assembly-from-scratch
Last synced: 3 months ago
JSON representation
Source code for the book Compiling to Assembly from Scratch https://keleshev.com/cas
- Host: GitHub
- URL: https://github.com/keleshev/compiling-to-assembly-from-scratch
- Owner: keleshev
- Created: 2020-06-24T19:31:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-27T14:59:37.000Z (over 1 year ago)
- Last Synced: 2024-05-12T01:34:36.758Z (6 months ago)
- Language: TypeScript
- Homepage: https://keleshev.com/cas
- Size: 137 KB
- Stars: 249
- Watchers: 14
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - keleshev/compiling-to-assembly-from-scratch - Source code for the book Compiling to Assembly from Scratch https://keleshev.com/cas (TypeScript)
- awesome-list - compiling-to-assembly-from-scratch - to-assembly-from-scratch-the-book | keleshev | 161 | (TypeScript)
README
# Compiling to Assembly from Scratch
This repository contains source code from the book [Compiling to Assembly from Scratch](https://keleshev.com/cas), 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 typescriptNow 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 typescriptInstall 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](https://keleshev.github.io/compiling-to-assembly-from-scratch/) is available as well.
```bash
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.