0% found this document useful (0 votes)
19 views5 pages

Fibonacci 8086 Lab Report

Fibonacci series

Uploaded by

Akhil King
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Fibonacci 8086 Lab Report

Fibonacci series

Uploaded by

Akhil King
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lab Report: Fibonacci Series in 8086

Lab Report: Fibonacci Series in 8086

Aim
To write an 8086 assembly program using EMU8086 software to generate and display the Fibonacci
series up to N terms.

Apparatus
1. Personal Computer with EMU8086 Software installed.
2. 8086 Microprocessor simulator (EMU8086).
3. Keyboard and Monitor.

Theory (200 words approx)


The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding
ones, starting from 0 and 1. Mathematically, it is expressed as:

F(0) = 0, F(1) = 1, F(n) = F(n-1) + F(n-2) for n >= 2

Fibonacci numbers are widely used in mathematics, computer algorithms, and even in nature. In
assembly programming for the 8086 microprocessor, registers are used to store intermediate
results, typically AX, BX, CX, DX. The program initializes the first two terms and iteratively adds
them to generate subsequent terms. The LOOP instruction helps repeat addition for the required
number of terms. Output is displayed using DOS interrupt 21H. Using EMU8086, the program can
be tested without hardware. This teaches loops, addition, and register manipulation.

Algorithm
1. Start the program.
2. Initialize first two terms (0,1).
3. Read number of terms N.
4. Display first two terms.
5. Loop from 3 to N:
- Add previous two terms.
- Store sum in register.
- Display sum.
- Update previous terms.
6. End program.

Procedure
1. Open EMU8086 software.
2. Write the assembly code.
3. Assemble and compile.
4. Run program and input N.
5. Observe output.
6. Verify manually.

Precautions
1. Initialize registers.
2. Use loop counters correctly.
3. Display values properly.
4. Avoid memory overwriting.

8086 Assembly Program (EMU8086)


.MODEL SMALL
.STACK 100H
.DATA
msg1 DB "Enter the number of terms: $"
msg2 DB 0DH,0AH,"Fibonacci series: $"
num DB ?
fib1 DW 0
fib2 DW 1
temp DW ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
LEA DX,msg1
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H
MOV num,AL
LEA DX,msg2
MOV AH,09H
INT 21H
MOV AX,fib1
CALL DISP_NUM
MOV AX,fib2
CALL DISP_NUM
MOV CX,num
SUB CX,2
NEXT_TERM:
MOV AX,fib1
ADD AX,fib2
MOV temp,AX
MOV AX,temp
CALL DISP_NUM
MOV AX,fib2
MOV fib1,AX
MOV AX,temp
MOV fib2,AX
LOOP NEXT_TERM
MOV AH,4CH
INT 21H
MAIN ENDP
DISP_NUM PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV BX,10
XOR CX,CX
DIV_LOOP:
XOR DX,DX
DIV BX
PUSH DX
INC CX
CMP AX,0
JNE DIV_LOOP
PRINT_LOOP:
POP DX
ADD DL,30H
MOV AH,02H
INT 21H
LOOP PRINT_LOOP
POP DX
POP CX
POP BX
POP AX
RET
DISP_NUM ENDP
END MAIN

Results
- Input: Number of terms = 7
- Output: 0 1 1 2 3 5 8

Calculation
Term 1: 0
Term 2: 1
Term 3: 0+1 = 1
Term 4: 1+1 = 2
Term 5: 1+2 = 3
Term 6: 2+3 = 5
Term 7: 3+5 = 8

Conclusion
The program successfully generates the Fibonacci series up to N terms using EMU8086. It
demonstrates loops, arithmetic operations, register manipulation, and DOS interrupts. The
experiment helps understand iterative logic, subroutine use, and low-level programming concepts.

You might also like