Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code this in ARM Use the following algorithm to calculate the nth number in the fibonacci sequence. Inputs will be from 1 to 1 0
Code this in ARM
Use the following algorithm to calculate the nth number in the fibonacci sequence. Inputs will be from to Input of should return input of should return input of should return input of should return input of should return and so on
procedure fibargument: n
return fibn fibn
You must use this argument. Yes, I know every caution you've been given to NEVER use such an algorithm. This is an exercise in understanding recursion and calling procedures in assembly language.
If you use a loop or an equivalent to a caseswitch table, your score on the assignment will be
Requirements and Specifications
Your input cannot be stored as a global variable at any point. This means you cannot store it at a data section address, even when accepting them from scanf; they must be returned from scanf on the stack.
XX are global variables. You may not use XX in your recursive function. If you want, you may use XX in your main function. You can use any registers you want to in your main function.
A recursion procedure requires:
Allocate stack space
Save the return address and argument on the stack
Recursively call procedure with BL
Unwind the stack by restoring the return address and arguments and deallocating stack memory
If the code is not recursive, ie uses a loop or a the equivalent of a caseswitch table, your score will be
Hints and Warnings
You must put the local values and return address on the stack before any bl call, and restore the argument and the return address after the bl call.
Skeleton Code:
section data
inputprompt : asciz "Please enter a number betwen and
inputspec : asciz d
fib : asciz d
oobmess : asciz "Input is out of bounds
section text
global main
main:
# branch to this label on program completion
exit:
mov x
mov x
svc
ret
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