Projects
All projects

C-to-MIPS compiler.

Translating C into MIPS assembly

  • C++
  • Shell
  • Make
  • Yacc
  • Lex

Overview

This project contains two components:

  • Test bench written in Shell
  • C-to-MIPS Compiler written in Yacc, Lexer and C++

Translating the C language to the MIPS assembly language was the final project of my 2nd-year Compilers module. Because C is relatively simple, it was a great language to give insight into what a compiler does under the hood.

The development of this compiler was inspired by the ANSI C Yacc Grammer and the process was split into stage starting from basic variable assignment to more advanced features like case statements.

The test bench uses a set of test cases written in C. Each test case would be compiled using GCC which is an established compiler and also with the test compiler. Both compiler results are then fed into QEMU which is an emulator that runs the MIPS code. Both results are then compared, the test compiler should imitate the GCC compiler.