Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question A) The MIPS ISA Computing a Fibonacci Number The Fibonacci number Fn is recursively defined as F (n) = F (n 1) + F

Question A)

The MIPS ISA

Computing a Fibonacci Number

The Fibonacci number Fn is recursively defined as F (n) = F (n 1) + F (n 2),

where F (1) = 1 and F (2) = 1. So, F (3) = F (2) + F (1) = 1 + 1 = 2, and so on.

Write the MIPS assembly for the fib(n) function, which computes the Fibonacci number F (n):

int fib(int n) {

int a = 0; int b = 1; int c = a + b;

while (n > 1) {

c = a + b;

a = b;

b = c;

n--;

}

return c;

}

Remember to follow MIPS calling convention and its register usage (just for your reference, you may not need to use all of these registers):

The argument n is passed in register $4.

The result (i.e., c) should be returned in $2.

$8 to $15 are caller-saved temporary registers.

$16 to $23 are callee-saved temporary registers.

$29 is the stack pointer register.

$31 stores the return address.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

What is the purpose of corrected Rand index?

Answered: 1 week ago

Question

4. Develop a self-directed learning module.

Answered: 1 week ago

Question

2. Provide recommendations for effective on-the-job training.

Answered: 1 week ago