I have 2 functions in c that I would like to see what they would look like in mips and this is because I need some examples to study and use for reference because I am a beginner in mips. I am also using qtspim.
Recursive function:
int my_fib(int n){
if (n==0)
return 2;
else if (n==1)
return 3;
else
return my_fib(n-1)+my_fib(n-2);
}
A function with a pointer:
int set(int a[], int n, int v)
{
int i;
for (i=n-1; i >= 0; i--) {
a[i] = v;
}
return i;
}
I would be very thankful if anyone could convert these to mips and give me an explanation of each step so I can get an idea on how to do other functions like these.