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.
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
|Memory Location||OPCODE||Operand||Label||Hex Code|