Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

EXPERIMENT NO.

TITLE: Add an array of N numbers.

AIM: Write 8086 Assembly language program (ALP) to add an array of N numbers stored
in the memory

THEORY:

Explanation:
Consider that a block of N bytes is present at source location.
Let the number of bytes N=10
We have to add these N bytes
We will initialize this as count in the CX register
SI register contain source address which will act as pointer.
Clear direction flag.
Using ADD instruction add the contents byte by byte of the block.
Increment SI to point to next element.
Decrement the counter and add the contents till all the contents are added.
Result is stored in AL.
Display the contents using display routine.
Example : Block Data :01 02 03 04 05 06 07 08 08 0A
Result: 01+02+03+04+05+06+07+08+09+0A=37 H

Algorithm :

Step 1: Initialise the data segment.

Step 2: Initialise SI as pointer with source address.

Step 3: Initialise CX register with count.

Step 4: Initialise direction flag to zero.

Step 5: Add data,byte by byte.

Step 6: Increment pointer ie. SI

Step 7: Decrement pointer CX.

Step 8: Check for count in CX,if not zero goto step 5 else goto step 9.

Step 9: Display the result of addition.

Step 10. Stop.


Flowchart:

Start

Initialise Data segment

Initialise pointer as SI with source


address

Initialise CX=count

DF=0

Sum=sum+[pointer]

Increment pointer SI

Decrement count in CX

count=0

Display the result

Stop

Conclusion:

You might also like