C to MIPS compiler
This program will use the g++ compiler to turn provided C code into MIPS assembly language.
Note that the assembly code produced is suitable for use on a real production MIPS machine, but will NOT work as-is in SPIM. This is for a few reasons:
This operation is basically the same as doing g++ -S mycode.c on your local command line, except that will output assembly lanuage specific to your platform (e.g., Intel x86 on PC/Mac). This tool uses a cross compiler to generate MIPS assembly instead of native assembly language, and is provided because installing a MIPS cross compiler can be annoying.
- This code includes directives (such as .set, .type, etc.) that are intended to support linking and debugging. These are not MIPS instructiosn, and are not supported in SPIM.
- This code is built for the Linux Application Binary Interface (ABI), meaning that system calls and library routines work differently than SPIM.
- This code is built to support a MIPS peculiarity called "delayed branches", where the instruction after a jump or branch is guaranteed to execute even if the branch takes place. This feature is intended to ease pipelining in MIPS, but is disabled in SPIM by default.
- This code is built to support a MIPS peculiarity called "delayed loads", where load instructions don't "happen" until a full instruction after the load. Again, this feature is intended to ease pipelining in MIPS, but is disabled in SPIM by default.
Do not attempt to use this tool to "automate" homework questions involving MIPS assembly programming. Your code will not work in SPIM for the reasons above and you'll spend more time adapting it than if you'd just written it from scratch. Also, code generated by compiler has a detectable structure, which we'll check for.