Some problems encountered during the compilation of MIPS-Based C language compiler programs, mips Compiler

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.