A C source file can be compiled to MIPS assembly using the -S switch, such as in bin/c_compiler -S <file>`.
A Segfault bytecode file can be compiled to MIPS assembly using the -ir and -S switches together, such as in bin/c_compiler -ir -S <file>.
Mips code can be output to a file using the -o <output_file> switch, such as in bin/c_compiler -S <input_file> -o <output_file>
An interpreter for SegFault bytecode with a working stack has been included in the compiler.
=== Normal Mode
The interpreter can be run using the -vm switch & takes a single C source file & runs the last function in the file, calling it with any integer arguments supplied on the command line, such as in bin/c_compiler -vm <input_file> <arg1> ….
A test script, test.sh, has been included which will run any tests 1 subdirectory deep in the compiler_tests folder.
An indication is given as to whether the test passed or failed, and if it failed a reason is given.
The percentage of tests passed is printed at the end of testing.
| Syntax | Usage | 
|---|---|
| 
 | Define a function  | 
| 
 | Declare a global variable  | 
| Syntax | Usage | 
|---|---|
| 
 | Initialises a static space in the program data at compile time for  | 
| 
 | Declare a subsection of an array (as stated in an initialiser list) & initialise it to  | 
| Syntax | Usage | 
|---|---|
| 
 | Finds the memory location of the object in  | 
| 
 | Allocate  | 
| 
 | Call  | 
| 
 | Advises the compiler of a variable’s  | 
| 
 | Trim the local stack to  | 
| 
 | Unconditionally jump to  | 
| 
 | Create  | 
| 
 | Finds the memory location pointed to by  | 
| 
 | Copy the value of  | 
| 
 | Return the value in register 0 to the calling function (this is fine for all functions as return value of void functions is undefined) | 
| 
 | Stores the value in  | 
| 
 | Branch to  | 
| 
 | Perform the operation specified in  | 
| Argument | Meaning | 
|---|---|
| 
 | Register  | 
| 
 | The  | 
| 
 | The  | 
| 
 | A literal with value  | 
| 
 | A global variable with name  | 
| 
 | A literal with value  | 
| 
 | The label  | 
| 
 | A type with "reference level"  |