Skip to content

EonP/C-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C-Compiler

A C compiler that compiles a subset of C, which is defined by the syntax grammar.


Built-in functions

void print_s(char* s);
void print_i(int i);
void print_c(char c);
char read_c();
int read_i();
void* mcmalloc(int size);

Requirements

A recent JDK version (21 or higher)

javac -version

Apache Ant as the build system

ant -version

Using the compiler

To run a C program with this compiler:

  1. Place your C source file inside the c_files/ folder (for example: c_files/test.c)

  2. In the project root directory, run:

./compile_and_run.sh c_files/test.c
  1. The compiler will:
    • Build the project using Ant (ant build)
    • Compile the C file into MIPS assembly -> the generated assembly file will appear in the asm_files/ folder (e.g. asm_files/test.asm)
    • Execute the MIPS program automatically using the MARS simulator in tools/ folder

Try it out!

Clone the project and from the root directory, run

./compile_and_run.sh c_files/tictactoe.c

or

./compile_and_run.sh c_files/fib.c

About

A C compiler that compiles a subset of C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published