Question: . section . data input _ prompt : . asciz Please enter a number betwen 1 and 1 0 input _ spec : .
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:
print greeting and ask for n between
ldr xinputprompt
bl printf
sub sp sp #
read inputted number
ldr xinputspec
mov x sp
bl scanf
check for out of bound input
ldr xsp
compare if value inputted is less than
cmp x
blt checkOutOfBounds
compare if value inputted is greater than
cmp x
bgt checkOutOfBounds
mov x x
bl recurse
ldr x recurse
bl printf
b exit
checkOutOfBounds:
ldr x oobmess
bl printf
b exit
basecase:
mov x #
ret
basecase:
mov x #
ret
recurse:
cmp x #
beq basecase
cmp x #
beq basecase
allocate stack space for call with n
sub sp sp #
str xsp #
str xsp
sub x x #
bl recurse
load result from fibonaccin into x
str xsp #
ldr xsp
ldr xsp #
add sp sp #
sub x x #
bl recurse
add x x x
ret
# branch to this label on program completion
exit:
mov x #
mov x #
svc #
It is a fibonacci sequence procedure fib
argument: n
return fibnfibn
should return base case
should return base case
should return
should return
should return
should return
should return
should return
should return
should return
For some reason the program is printing the "Please enter a number"... then automatically printing "Input is out of bounds and quitting"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
