8085 program to add numbers in an array

MicrocontrollerMicroprocessor8085

In this program we will see how to add a blocks of data using 8085 microprocessor.

Problem Statement

Write 8085 Assembly language program to add numbers in an array, where the size of the array is N. The value of N is provided.

Discussion

In this problem we are using location 8000H to hold the length of the block. The main block is stored from address 8010H. We are storing the result at location 9000H and 9001H. The 9000H holding the lower byte, and 9001H is holding the upper byte.

Repeatedly we are taking the number from the memory, then adding it with accumulator and increase the register E content when carry flag is set. Initially E is cleared.

Input

AddressData
.
.
.
.
.
.
800008
.
.
.
.
.
.
8010AF
80112E
80127C
801381
80142C
8015BF
8016FB
80171C
.
.
.
.
.
.

Flow Diagram

Program

AddressHEX CodesLabelsMnemonicsComments
F00021, 00, 80
LXI H, 8000HLoad the address to get count of numbers
F0034E
MOV C,MLoad C with the count value
F00421, 10, 80
LXI H, 8010HLoad HL with the starting address
F007AF
XRA AClearAccumulator
F0085F
MOV E, AClear the E register also
F00986LOOPADD MAdd Memory content with Accumulator
F00AD2, 0E, F0
JNC SKIPWhen carry is false, skip next task
F00D1C
INR EIncrease E,when C flag is set
F00E0DSKIPDCR CDecrease C register by 1
F00F23
INX HPoint to next location
F010C2, 09, F0
JNZ LOOPWhen Zero is false, go to LOOP
F01321, 00, 90
LXI H,9000HLoad address to store result
F01677
MOV M,ASave accumulator content
F01723
INX HIncrease HLpair
F01873
MOV M,EStore carry
F01976
HLTTerminate the program

Output

AddressData
.
.
.
.
.
.
9000DC
900103
.
.
.
.
.
.
raja
Published on 17-Jan-2019 16:01:52
Advertisements