Some problems encountered during the compilation of MIPS-Based C language compiler programs, mips Compiler
When I used Java to write a C-(simplified C Language) compiler, I encountered a long problem: After testing C-code input and executing parser and typechecking, A complete MIPS code is successfully compiled. However, when the MIPS code is copied to the QtSpim Simulator for execution, the simulator reports an error.
Problem Analysis: you cannot directly locate the problem at the beginning. You can only find the error code location in the error message provided by QtSpim, and find that the problem lies in the code that passes parameters between functions.
Error message: Instruction references undefined symbol at 0x00400014
To locate the specific type of the problem, simplify the input C-code function to a separate main function, then, we gradually add global variables, local variable declarations, flow control statements, and function declarations and calls, and finally find that the problem lies in the parameter passing of the function.
After an error code is found, the problem is that the offset of the parameter is aligned when the function is called, but the code for alignment is incorrect. After the error is corrected, the problem can be solved.