8085 Program to Add Numbers in an Array



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

Address Data
.
.
.
.
.
.
8000 08
.
.
.
.
.
.
8010 AF
8011 2E
8012 7C
8013 81
8014 2C
8015 BF
8016 FB
8017 1C
.
.
.
.
.
.

Flow Diagram

Program

Address HEX Codes Labels Mnemonics Comments
F000 21, 00, 80
LXI H, 8000H Load the address to get count of numbers
F003 4E
MOV C,M Load C with the count value
F004 21, 10, 80
LXI H, 8010H Load HL with the starting address
F007 AF
XRA A ClearAccumulator
F008 5F
MOV E, A Clear the E register also
F009 86 LOOP ADD M Add Memory content with Accumulator
F00A D2, 0E, F0
JNC SKIP When carry is false, skip next task
F00D 1C
INR E Increase E,when C flag is set
F00E 0D SKIP DCR C Decrease C register by 1
F00F 23
INX H Point to next location
F010 C2, 09, F0
JNZ LOOP When Zero is false, go to LOOP
F013 21, 00, 90
LXI H,9000H Load address to store result
F016 77
MOV M,A Save accumulator content
F017 23
INX H Increase HLpair
F018 73
MOV M,E Store carry
F019 76
HLT Terminate the program

Output

Address Data
.
.
.
.
.
.
9000 DC
9001 03
.
.
.
.
.
.
Updated on: 2019-07-30T22:30:24+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements