What Does Li $V0,10, in Mips?

I am just starting with Mips so this may sound simple but:
When I wrote the code above without li $v0,10 instruction , I got an error message: memory adress out of bound
When , I added it , it worked with no warnings.
What does this means?

.text
.globl main
main:
 li $t1,27
li $t2,2
mulou $t3,$t1,$t2
li $v0,10
syscall

1 Answer

li itself just loads an immediate into a register. In this particular case, the service routine on the other side of syscall looks at the value in $v0 to tell what function is requested. 10 is the code for exit (see list of system calls supported by spim). If you don't set $v0 then some random function will be performed based on what value $v0 happens to contain. Likely it isn't going to be exit so the cpu tries to continue executing whatever is after your code in memory which will sooner or later crash.

5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest