Question: fill in the blank 1. Implement the following C code in MIPS assembly. int fib (int n) { if (n==0) return 0; else if (n==1)

fill in the blank

fill in the blank 1. Implement the following C code in MIPS

1. Implement the following C code in MIPS assembly. int fib (int n) { if (n==0) return 0; else if (n==1) return 1; else return fib(n-1) + fib(n-2); Fill in the blanks of the partial answer. Each blank is one instruction only. fib: addi $sp, $sp, -12 #make room to save 3 values on stack # push $ra on stack # push $s0 on stack SW $a0, 0($sp) # push $a0 on stack #the following instructions are for the if-else-else statement # if n!=0, jump to testnis 1 #else fib(0) = 0 j rtn testnis1: # return # set $t0 to 1 addi $t0,$0, 1 # if n!=1, jump to gen #else fib(1) = 1 add $v0, $0, $t0 j rtn gen: subi jal add fib $50, $v0, $0 # calculate n-1 #call fib(n-1) #copy fib(n-1) to $so

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!