C to MIPS32 Compiler

The compiler was made to translate C code to MIPS assembly. It was then tested using qemu and simulating the MIPS processor to run the binary.

*** What is a compiler?

A Compiler is a program that transforms code written in one language into another language. This is normally done to transform a higher level language such as C, into a lower level language such as assembly.

Figure 1: Compiler Workflow

Figure 1: Compiler Workflow

*** Project

The project was separated into three parts: lexer, parser and the actual compiler. The lexer was written in flex, which then got passed to the parser that we wrote in bison. The AST (Abstract Syntax Tree) that was output by bison was then traversed in the compiler and the corresponding assembly code was output by the compiler.

In our second year we were given a coursework to write a compiler that would take in C89 code and compile it to MIPS32 assembly. We then used the gcc assembler to compile that to a binary and used qemu to simulate a MIPS processor and run the binary.

** Lexer

TODO Part about lexer

** Parser

TODO Part about parser

** Compiler

TODO Part about compiler