infinite loop in simple mips

前端 未结 2 1482
挽巷
挽巷 2021-01-26 09:33

I\'m trying to learn about $ra, so the output I want is \"mainfunction1main\" , by main calling function1, function1 returning to main, and main finishing. but for some reason I

相关标签:
2条回答
  • 2021-01-26 09:43

    You need to return at the end of main. At the moment you'll just fall through to function1 again, which will jump back to main, and then fall through again, etc...

    0 讨论(0)
  • 2021-01-26 09:54

    Like JasonD said, you need to exit your program at the end of main. All you need to do is append two lines at the end of main, like so:

    main:
        # ... previous stuff
    
        li $v0, 10                                                                                                                                                               
        syscall
    

    This will load and run the exit system call (which has a code of 10.)

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