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);A recent JDK version (21 or higher)
javac -versionApache Ant as the build system
ant -versionTo run a C program with this compiler:
-
Place your C source file inside the
c_files/folder (for example:c_files/test.c) -
In the project root directory, run:
./compile_and_run.sh c_files/test.c- 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
- Build the project using Ant (
Clone the project and from the root directory, run
./compile_and_run.sh c_files/tictactoe.cor
./compile_and_run.sh c_files/fib.c