I want to implement a recursive program in assembly for MIPS. More specifically, I want to implement the well-known Fibonacci function.
Here’s the implementation in C:
int fib(int n) {
if(n<2)
return 1;
return fib(n-1)+fib(n-2);
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is the code to do a recursive factorial function in MIPS assembly. Changing it to do Fibonacci is left as an exercise to the reader. (Note: delay slots aren’t optimized in this code, as it’s designed for readability.)