A C compiler that targets a VM, written is Rust
-
Virtual Machine:
An emulation of a CPU that has 8 regiters, can execute instructions with 17 different opcodes, use memory, and perform IO with memory mapped registers.
-
C compiler:
A C compiler that targets the VM's instructions set.
list of compiler features
- Evaluate expressions
- Local & global variables
- Flow control: if/else & loops
- Scopes
- Functions
- Arrays & structs
- Pointers
- C strings
Includes a linker and a basic preprocessor.
Lexing & Parsing is performed using pycparser.
-
Operating System:
Can load programs to memory, has an assembler and a assembly-level debugger. Offers a minimal libc with print functions and malloc & free implementation.
- To run the tests:
./run_tests
- To compile & run a program:
cargo run run <main_source_file> <optionally other files to link with>
- To compile & debug a program:
cargo run debug <main_source_file> <optionally other files to link with>
- Improve preprocessor: Add #define, #ifdef, macros.
- Add typedef, check type validity at compile time.
- Ultimately the goal is to compile gnu libc