Text: I need help with my last computer science homework and wrote the code, but I'm not sure if it's correct. I want to compare it with someone to see if it's similar.
Obtain a MIPS assembly function equivalent to the following C function. Assume Cint is of size 4 bytes. Arguments a and n are passed respectively in $a0 and $a1, and the return value in $v0. Your assembly function must be recursive. The local variable s should be allocated on the stack.
int arrsum(int a[], int n) {
int s = 4;
if (!n) {
return 0;
} else {
return a[0] + arrsum(a+1, n-1) + s;
}
}