Write an 8085 program to add a series of 8-bit hexa-decimal numbers - ChromeTechny
Home » Write an 8085 program to add a series of 8-bit hexa-decimal numbers
8085

Write an 8085 program to add a series of 8-bit hexa-decimal numbers

So far in this program series, we had added or either subtracted two hexadecimal or decimal numbers. But in this program, we are going to add not two but 5 8-bit hexadecimal numbers, thereby making it a sum of a series program.
Before we move on to the program, there are few things which you need to know, the first being is the use of counter or loop, as we are going to add a series of numbers, we are going to use a loop to check whether the memory content has a data or not. Till the memory location will contain data, the loop will continue.

Next, if you want to adjust carry which may get generated, you need to use another loop. But in order to make the program simple and less complicated, we are going to leave the carry.

Now as far as memory location is concerned, as we are going to add 6 8-bit hexadecimal numbers, we are going to use 6 memory location to store the numbers and one more to store the result of the addition.

In this 8085 program, we are going to use 2000H to store the numbers of 8-bit hexadecimal numbers and 2001H – 2005H memory location to store the values, and lastly, 2006H memory location to store the result which we will get after the addition.

Input:

LXI H, 2000H
MOV C, M //we will use C register as a counter hence we are copying the content of 2000H ML in C register
MVI A, 00H to make sure that the accumulator doesn’t have any previously stored value we make its content as 00
INX H // we now increment the HL register so that it can point to 2001H memory location
MOV B, M // next, we copy the content of 2001H memory location to B register
ADD B// now we perform the addition operation with the content of accumulator
DCR C// next, we decrement the content of C register by 1
JNZ 200CH // Jump No Zero is acting as a loop counter so that the above instructions keep on continuing until and unless all the values are added
INX H // we increment the memory location so that HL register could point to 2006H memory location
MOV M, A //now we move the result of the addition to 2006H memory location
HLT

 

Programming Details
Memory Location OPCODE Operand Label Hex Code
2006 LXI H, 2000H 21H
2007 00H
2008 20H
2009 MOV C,M 4EH
200A MVI A,00H 3EH
200B 00H
200C INX H 23H
200D MOV B,M 46H
200E ADD B 80H
200F DCR C 0DH
2010 JNZ 200C C2H
2011 0CH
2012 20H
2013 INX H 23H
2014 MOV M,A 77H
2015 HLT 76H

About the author

Ayan