How do I return a value from the main function in MIPS?

后端 未结 1 789
鱼传尺愫
鱼传尺愫 2020-12-11 11:15

Say I want to write the following C program in MIPS:

int main () {
  return 5;
}

When I try the following MIPS code in MARS:



        
相关标签:
1条回答
  • 2020-12-11 11:48

    Use syscall 17:

    exit2 (terminate with value)
    ----------------------------
    $v0 = 17
    $a0 = termination result
    

    Note that "If the MIPS program is run under control of the MARS graphical interface (GUI), the exit code in $a0 is ignored."

    0 讨论(0)
提交回复
热议问题