8085 program to find the sum of a series


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 N 1-byte numbers. 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 AClear accumulator
F0085F
MOV E, AClear the E register also
F00986LOOPADD MAdd Memory content with Accumulator
F00AD2, 0C, F0
JNC SKIPWhen Carry flag is 0, 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 HL pair
F01873
MOV M, EStore carry
F01976
HLTTerminate the program

Output

AddressData
.
.
.
.
.
.
9000DC
900103
.
.
.
.
.
.

Updated on: 30-Jul-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements