0% found this document useful (0 votes)
447 views

Program To Calculate Fibonacci Numbers in Assembly Language Using Visual Studio PDF

The document describes a program written in assembly language that uses a loop to calculate the first seven Fibonacci numbers. It provides the code for the program, which initializes an array to store the values, uses ECX as a counter, and loops through adding the previous two values in the array to calculate the next. It is presented as an exercise solution on a programming tutorials blog about assembly language fundamentals.

Uploaded by

Dilawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
447 views

Program To Calculate Fibonacci Numbers in Assembly Language Using Visual Studio PDF

The document describes a program written in assembly language that uses a loop to calculate the first seven Fibonacci numbers. It provides the code for the program, which initializes an array to store the values, uses ECX as a counter, and loops through adding the previous two values in the array to calculate the next. It is presented as an exercise solution on a programming tutorials blog about assembly language fundamentals.

Uploaded by

Dilawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

http://csprogrammingtutorial.blogspot.com/2017/12/Fibonacci-Numbers.html 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)

http://csprogrammingtutorial.blogspot.com/2017/12/Fibonacci-Numbers.html 2/3

You might also like