MIPS assembly language
Consider the function with header: int foo(int s, int n, int a, int b).
Write MIPS assembly code for the following statement located inside the above function:
I was told the answer is
add $v0, $a0, $a1
but I don’t understand why... I know
add $v0, $a0, $a1 means
- Register $a0 stores the first argument i.e., a0= s
- & Register $a1 stores the second argument i.e, a1=n
- add instruction adds the values in $a0 and $a1 and saves the result in register $v0.
- The value stored in register $v0 is the one to be returned from the function.
but what about the