Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help creating a MIPS program. My teacher says some recursive procedu

ID: 3790496 • Letter: I

Question

I need some help creating a MIPS program. My teacher says some recursive procedures can be implemented iteratively without using recursion and that Iteration can significantly improve performance by removing the overhead associated with procedure calls.

Help me write a MIPS procedure to compute the n th Fibonacci number F(n) where F(n) = 0, if n = 0; 1, if n = 1 and F(n-1) + F(n-2), otherwise.

Base your algorithm on the recursive process:

int fib(int n){
if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n-1) + fib(n-2);

----------------------------------------------------------

Requirements: Ask the user for “n” Fibonacci number; then display all the numbers upto “n”. For example:

-->"Please enter the nth Fibonacci number to be displayed: "

-->6

-->0, 1, 1, 2, 3, 5

Explanation / Answer

.data msg1:.asciiz "Give a number : " .text .globl main main: li $v0,4 la $a0,msg1 syscall li $v0,5 syscall add $a0,$v0,$zero jal fib add $a0,$v0,$zero li $v0,1 syscall li $v0,10 syscall fib: #a0=a #if (a==0) return 0; #if (a==1) return 1; # int x($t1),y($t2),z($t3),i($t4); # for (x=0,y=0,z=1,i=1;i