Posted By : Anthony Darryl Abeyta
Posted On : 2 November 2014
Keywords : 8086 Fibonacci Series, 8086 fibonacci Sequence, Assembly Language fibonacci Series, Assmbly Language fibonacci Sequence, Create A Program in 8086 assembley language using the emu8086 software generating and displaying the first 5 terms of a Fibonacci sequence.

8086 Assembly Language Program Fibonacci Series

Problem Statement

Create a program in 8086 assembler language using the emu8086 software generating and displaying the first 5 terms of a Fibonacci sequence.


What Is Fibonacci number



In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,144,....

By definition, the first two numbers in the Fibonacci sequence are 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

Fn = F{n-1} + F{n-2}

with seed values

F1 = 1; F2 = 1

or

F0 = 0; F1 = 1.


Expected Output


8086 Fibonacci Number Sample Code

Sample Code


;***********************************************************************
;Module Name: program2_AnthonyAbeyta.asm
;Author:      Anthony Abeyta
;Date:        30 Nov 2014
;Purpose:     Fibonacci Seq. First 5 terms displayed.
;Ownership:   Anthony Abeyta
;***********************************************************************
;***********************************************************************
;Listing Contents:
;  Global Data
;    None
;  Functions/Procedures/Methods
;    fibLoop 
;    msg1
;    fibTerm
;***********************************************************************
org 100h    
    
    lea DX, msg1           
    mov AH, 09h            
    int 21h                                               
                            
    mov DL, 20h             
    mov AH, 02h             
    int 21h                          
 
    mov BH, 1
	mov DH, 1 
    mov CX, 5
    
;***********************************************************************
;Name:       fibLoop
;Purpose:    First 5 Fib Terms
;On Entry:
;  Depends on CX as a counter
;On Exit
;  None.
;Process:
;  Step 01 - Offset DL
;  Step 02 - Display
;  Step 03 - Save DX current state
;  Step 04 - AL = DL 
;  Step 05 - AH = DH
;  Step 06 - AH = AL 
;  Step 07 - BH = AH
;  Step 08 - Returns DX
;  Step 09 - Loop 
;*********************************************************************** 
		
    fibLoop:
		or DL, 30h
		mov AH, 02h
		int 21h
		mov DL, DH
		mov DH, BH
		    
		push DX
	        mov AL, DL
	        mov AH, DH
	        add AH, AL
	        mov BH, AH 
	    pop DX
	loop fibLoop
		
	ret
msg1 db "     FIBONACCI FIRST 5 TERMS      ", 0Dh,0AH
     db " I start from 0 while others like", 0Dh,0AH
	 db " to include the 1 in the first term.", 0Dh,0AH, "$"
fibTerm db 12 Dup(0)



Run The Program Using Emu 8086


Anthony Darryl Abeyta

A US Army Veteran studying the world of Information Technology! I am a simple guy who is just looking to get his foot into the door.