Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.11 KB

README.md

File metadata and controls

36 lines (25 loc) · 1.11 KB

Adam Soutar's Source compiler

An all-the-way-down handwritten C compiler, just for fun :)

What?

ass compiles programs written in C down to x86-64 assembly code.

It has a tokeniser, parser and codegen module. You can run it like this to generate assembly:

ass input.c > output.s

Note: ass is not an assembler or linker. See compile.sh for assembling binaries

Implemented features

  • Variables Local, stack-based and global variables of all primitive types besides floats/doubles
  • Pointers Pointers, dereferencing, and the addressOf operator
  • Functions Functions + arguments can be defined and called
  • StdLib Call into standard library functions like printf
  • If statements With optional else
  • Loops Including unusual loop declarations like (;;)

Plus Probably more since I wrote this readme :)

Examples

See ./examples for some example code that ass can compile and run right now - including a FizzBuzz program!

Is it even a compiler if it can't do FizzBuzz?