Question
Modify the following ARM code so that it now has a main that simply calls a RECURSIVE fibonacci function with a single parameter of 16
Modify the following ARM code so that it now has a main that simply calls a RECURSIVE fibonacci function with a single parameter of 16 (that is retrieved from a memory labeled fibinput. This function will return the 16th fibonacci value and the main will then store only this one value back into memory in a memory location labeled fibnumber.
Here is the ARM lab That need to modify:
ldr R4, =copyPrms MOV R0, #0 MOV R1, #24 MOV R2, #1 again ADD R3, R2, R0 SUBS R1, R1, #1 MOV R0, R2 MOV R2, R3 str R3, [R4], #4 BNE again copyPrms DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 END
Here is what the recursive Java version of the code might look like:
public static int fibonacci(int number) { if (number == 1 || number == 2) { return 1; } return fibonacci(number-1) + fibonacci(number -2); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started