Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Write a recursive assembly subroutine that calculates the Fibonacci number. Fibonacci numbers are those that follow a special sequence lhke below 0. 1, 1,

image text in transcribed
3. Write a recursive assembly subroutine that calculates the Fibonacci number. Fibonacci numbers are those that follow a special sequence lhke below 0. 1, 1, 2, 3. 5. 8. 13. 21 34, 55, N Fibonacci number can be calculated with the following formula EN- 0 EN-1 F (N - 1) FIN- 2) otherwise The pseudo code of Fibonacci number function is like below unsigned int out-0 unsigned int N-5 2: unsigned int fib (unsigned int n 4: if n 1) returnni 7: 8: return fib (n-1) fib (n-2) int main (void) 10: outfib (N) while(2) 12: 13: Follow the instructions below . Create a new project and add a new assembly file "rec fibonaccis to the project. . Define two unsigned integer variables out, and N in DATA area. Initialize the variables with the specified values in the above code. Use nyData as DATA area's nane Define a function . main and Fib in CODE area. Use myCode as CODE area's . In main function, a. Load the value of N from memory and pass it to Fib function as an input parameter in RO. b. Get the return value from Fib function and store it to out variable in memory c. For the while loop in line 12, use stop B stop as in the lecture slide. In Fib function, The function should run recursively as shown in the pscudo code. Use as many registers as needed. But, you should carefully preserve them by using stack as learned from the lecture. Return the calculation result in RO a. b. c

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago