12/9/2018 5.
Program to calculate Fibonacci Numbers in Assembly Language using Visual Studio
Programming Tutorials
SUBSCRIBE
5. Program to calculate Fibonacci Numbers
in Assembly Language using Visual Studio
December 13, 2017
Chapter 3
Assembly Language Fundamentals
Assembly Language Programming Exercise
Problem # 5:
Write a program that uses a loop to calculate the first seven values of
the Fibonacci number sequence, described by the following formula:
Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2).
Solution:
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
count DWORD 5
array DWORD 7 DUP (1,1,?,?,?,?,?)
.code
main PROC
mov ecx, count
mov ESI, OFFSET array
Add ESI, TYPE array
Add ESI, TYPE array
[Link] 1/3
12/9/2018 5. Program to calculate Fibonacci Numbers in Assembly Language using Visual Studio
L1:
Programming Tutorials
MOV EAX,[ESI-4]
SUBSCRIBE
MOV EBX,[ESI-8]
ADD EAX,EBX
MOV [ESI],EAX
ADD ESI, TYPE array
Loop L1
INVOKE ExitProcess,0
main ENDP
END main
Let me know in the comment sec on if you have any ques on.
Previous Post:
Copying a Word Array to a DoubleWord array
Next Post:
Reverse an Array
ASSEMBLY BASICS ASSEMBLY LANGUAGE FOR X86 PROCESSORS CHAPTER 4
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE COMPUTER SCIENCE
DATA TRANSFERS ADDRESSING AND ARITHMETIC EXERCISE SOLUTION VISUAL STUDIO
Reactions: funny (0) interesting (0) cool (0)
[Link] 2/3