I hope you have gotten a clear idea on how you can do addition operation using 16-bit hexadecimal and decimal number.
In this program, we are going evaluate the above expression, which basically means the addition of three consecutive numbers, and all of them are 8-bit hexadecimal numbers.
As far as addressing mode is concerned, we are going to use indirect addressing mode. And the result will be stored in a memory location, not in a general purpose register.
Let a = A9H, which will be stored at the 2000H memory location, b = 2DH, which we will be storing in the 2001H memory location, and finally c = 1BH, which will be stored at the 2002H memory location.
After the evaluation, the final result will be stored at the 2003H memory location, so in total, we are going to use 4 consecutive memory locations.
LXI H, 2000H // using LXI H, we will use HL register to point at 2000H memory location
MOV A, M // we now store the content of 2000H memory location in the accumulator using the MOV instruction
INX H // we will increment the HL register as a result, it will point at 2001H memory location
ADD M // now we will perform the addition operation between the content of accumulator and the content of HL register pair
INX H // again we are going to use HL register pair to increment the ML which will now be pointing at 2003H memory location
ADD M // this time we are going perform the addition operation between the output of the first addition which has been stored in the accumulator with the content of HL register pair
STA 2003 // using STA we are going to store the content of accumulator in 2003H memory location
|Memory Location||OPCODE||Operand||Label||Hex Code|