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
Get step-by-step solutions from verified subject matter experts
