Write a .asm program that computes the Nth Fibonacci number. N will be provided in R0 and the output should be in R1
AREA RESET, CODE, READONLY
ENTRY
start MOV R1, #16 ; n = 16
MOV R3, #0 ; fn1 = 0
MOV R0, #1 ; fn = 1
MOV R2, #1 ; curr = 1
whn CMP R2, R1 ; while (curr < 1)
BHS endwhn ; {
ADD R2, R2, #1 ; curr = curr + 1
MOV R4, R0 ; tmp = fn
ADD R0, R0, R3 ; fn = fn + fn1
MOV R3, R4 ; fn1 = tmp
B whn ; }
endwhn
STOP B STOP
END
Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......
Get Answers For Free
Most questions answered within 1 hours.