8085 program to find the sum of a series of 8-bit numbers

In this program, we will write an 8085 program to find the sum of a series of 8-bit numbers assuming the sum to be 8-bit in the 8085 microprocessor with a program flow chart and explanation of the program. Here we will see the two programs, one will be assuming the sum to be 8-bit and the other one will be assuming the sum to be 16-bit.

Program 1

8085 program to find the sum of a series of 8-bit numbers assuming the sum to be 8-bit

Program Statement

Calculate the sum of a series of numbers. The length of the series is in memory location D000H. The series begins from D001H. Assuming the sum to be an 8-bit number so that carry can be ignored. Store the result in memory location E000H.

Explanation of Program

• We are given a series of numbers. The length of the series is stored at memory location D000 H. We will initialize register C as a counter with the length of the series.
• We will initialize the accumulator with 00 H so that the sum can be stored in the accumulator.
• The series begins at D001 H. So, we will initialize HL the register pair as a memory pointer to point the series.
• Using the add instruction, add the contents, of the accumulator with the contents of the memory location pointed by the HL register pair. The result of this addition will be stored in the A register.
• Then we will increment HL to point to the next memory location of the series. Decrement the count in register C. Continue this process till the count is zero i.e. all the numbers in the series are added.
• Store the result at memory location E000 H.

Example: Let D000 05 H i.e. series is of 5 numbers.

Result = 08 H + 12 H + 74 H + 34 H + 04 = C6H

E000 H = C6 H.

Program 2

8085 program to find the sum of a series of 8-bit numbers assuming the sum to be 16-bit

Program Statement

Calculate the sum of a series of numbers. The length of the series is in memory location D000H. The series begins from D001H. Assuming the sum to be a 16-bit number and Storing the result in memory locations E000H and E001H.

Explanation of Program

• We are given a series of numbers. The length of the series is stored at memory location D000 H. We will initialize register C as a counter with the length of the series.
• We will initialize the accumulator with 00 H so that the sum can be stored in the accumulator. Also, initialize register B = 00 H so that the higher byte of the sum can be stored.
• The series begins at D001 H. So, we will initialize HL the register pair as a memory pointer to point the series.
• Using the add instruction, add the contents, of the accumulator with the contents of the memory location pointed by the HL register pair. The result of this addition will be stored in the A register.
• Check for carry. If carry is 1 then increment register B.
• Then we will increment HL to point to the next memory location of the series. Decrement the count in register C. Continue this process till the count is zero i.e. all the numbers in the series are added.
• Store the result at memory locations E000 H and E001 H.

Example: Let D000 04 H i.e. series is of 4 numbers.

Result = 09A H +52 H + 89 H + 3E H = 1B3 H

E000 H = B3 H ,E001 H= 01 H

Assembly Language Program

Hello friends, my name is Trupal Bhavsar, I am the Writer and Founder of this blog. I am Electronics Engineer(2014 pass out), Currently working as Junior Telecom Officer(B.S.N.L.) also I do Project Development, PCB designing and Teaching of Electronics Subjects.

This site uses Akismet to reduce spam. Learn how your comment data is processed.