Experiment 5

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Experiment 5: ALP for

Average of N Numbers
and Fibonacci Series
BITS Pilani Department of EEE
Hyderabad Campus
ALPs to be completed

5.1 Find the average of N numbers.

5.2 Generation of the Fibonacci series.

Title| Presenter 2 BITS Pilani, Hyderabad Campus


5.1 Average of N numbers

Title| Presenter 3 BITS Pilani, Hyderabad Campus


5.1 Average of N numbers
MOV DX,0000H
MOV AX,0000H
MOV CX,0000H
MOV CX,[6000H]
MOV BX,5000H
AVG: ADD AX,[BX]
INC BX
INC BX
LOOP AVG
MOV CX,[6000H]
DIV CX
INT 03H

Title| Presenter 4 BITS Pilani, Hyderabad Campus


Review Questions

1. Why is INC BX is used twice?

2. Can we load decimal number in CX and compute the same?

3. Which addressing mode(s) are used in this programming?

4. Can you perform the average of the following array?


{4005H, 4005H, 4005H, 4005H}.

5. Repeat the problem with five numbers of 16-bit data and record the
output.

Title| Presenter 5 BITS Pilani, Hyderabad Campus


5.2 Fibonacci series
Each number is the sum of the two preceding ones, starting
from 0 and 1 as depicted below.

Fibonacci series

0, 1, 1, 2, 3, 5, 8, 13, 21......

Title| Presenter 6 BITS Pilani, Hyderabad Campus


5.2 Fibonacci series
MOV AX,0000H
MOV BX,0000H
MOV CX,0005H
MOV BX,5000H
FIB : MOV AX,0000H
ADD AX,[BX]
ADD AX,[BX+2]
MOV [BX+4],AX
INC BX
INC BX
DEC CX
JNZ FIB
INT 03H
Title| Presenter 7 BITS Pilani, Hyderabad Campus
Review Questions

1. What if the accumulator is not initialized to zero ?

2. Does it have any effect on output result if the accumulator


is not initialized to zero?

Title| Presenter 8 BITS Pilani, Hyderabad Campus

You might also like