ARM Assembly Code
The Fibonacci Sequence is a series of integers. The first two numbers in the sequence are both 1; after that, each number is the sum of the preceding two numbers.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
For example, 1+1=2, 1+2=3, 2+3=5, 3+5=8, etc.
The nth Fibonacci number is the nth number in this sequence, so for example fibonacci(1)=1, fibonacci(2)=1, fibonacci(3)=2, fibonacci(4)=3, etc. Do not use zero-based counting; fibonacci(4)is 3, not 5.
Your assignment is to write an assembler code (Fibonacci.s) that asks the user for the nth term in the Fibonacci sequence. Your program should then calculate the nth Fibonacci number and print it out.
For example, you program should produce the following outputs:
Enter Fibonacci term: 6
The 6th Fibonacci number is 8
Following is the assembly code for the Fibonacci series.
MOV AL, 00H
MOV SI, 500H
MOV [SI], AL
ADD SI, 01H
ADD AL, 01H
MOV [SI], AL
MOV CX, [0000H]
SUB CX, 0002H
L1:
MOV AL, [SI-1]
ADD AL, [SI]
ADD SI, 01H
MOV [SI], AL
LOOP L1
HLT
That was a nice
question to answer
Friend, If you have any doubts in understanding do let me know in
the comment section. I will be happy to help you further.
Thanks
Get Answers For Free
Most questions answered within 1 hours.