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

3. Write a recursive assembly subroutine that calculates the Fibonacci number. Fibonacci numbers are those that follow a special sequence like below: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, Nth Fibonacci number can be calculated with the following formula. F(N) if N = 1 = F(N-1) F (N -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) 5: if (n Follow thc instructions below .Create a new project and add a new assembly file "rec fibonacci.s" to the project. . Deline two unsigned integer variables out, and N in DATA area. Initialize the variables with the specified values in the above code. Use myData as DATA area's name Define a functionmain and Fib in CODE area. Use myCode as CODE area's name. 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 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 pseudo code. a. b. 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 Submit the rcc fibonacci.s filc to the Canvas. c. Capture the final out value in the memory plane of the debugger after executing the code and c opy the captured image below 3. Write a recursive assembly subroutine that calculates the Fibonacci number. Fibonacci numbers are those that follow a special sequence like below: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, Nth Fibonacci number can be calculated with the following formula. F(N) if N = 1 = F(N-1) F (N -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) 5: if (n Follow thc instructions below .Create a new project and add a new assembly file "rec fibonacci.s" to the project. . Deline two unsigned integer variables out, and N in DATA area. Initialize the variables with the specified values in the above code. Use myData as DATA area's name Define a functionmain and Fib in CODE area. Use myCode as CODE area's name. 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 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 pseudo code. a. b. 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 Submit the rcc fibonacci.s filc to the Canvas. c. Capture the final out value in the memory plane of the debugger after executing the code and c opy the captured image below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
