In the last two program, we have evaluated expressions which included only 8-bit hexadecimal and decimal number.

But in this program, we are going to use two 16-bit hexadecimal numbers and one 8-bit hexadecimal number.

Now, as far as addressing mode is concerned, for this program, we are not gonna use any specific kind of addressing mode rather we are gonna mix it up.


For this program, we are going to need in total seven memory locations. Starting from the 2000H memory location, we are going to store the first 16-bit hexadecimal number; 34ACH.

And then in the 2002H and 2003H memory location, we are going to store the second 16-bit hexadecimal number i.e. 1E9BH, and in finally in the 2004H memory location, we are going to store the 8-bit hexadecimal number 1AH.

Now, in order to store the result, we can use 2005H and 2006H memory location.


LHLD 2000H //the content of 2000H and 2001H memory location will be copied to HL register pair

XCHG //using XCHG instruction we are going to copy the content of HL register pair to DE pair

LHLD 2002H //now we load the content of 2002H into HL register pair

DAD D// now using DAD instruction we are going to add the content of HL register pair and DE register pair

MOV A, L //after performing addition operation you’ll need to copy the LSB to accumulator

MOV D, H //and then we’ll copy the MSB in D or any other general purpose register

LXI H, 2004H //using LXI we’ll point HL register to 2004H memory location

ADD M // and then we will perform the addition operation of the LSB with the 8-bit hexadecimal number

STA 2005H //next, using STA we’ll copy the content of accumulator in 2005H memory location

MOV A,D // now we’ll move the MSB to accumulator so that we could store it in a memory location

STA 2006H //finally we’ll store the MSB in 2006H memory location


Programming Details
Memory Location OPCODE Operand Label Hex Code
2007 LHLD 2000H 2AH
2008 00H
2009 20H
200C 02H
200D 20H
200E DAD D 19H
200F MOV A,L 7DH
2010 MOV D,H 54H
2011 LXI H,2004 21H
2012 04H
2013 20H
2014 ADD M 86H
2015 STA 2005 32H
2016 05H
2017 20H
2018 MOV A,D 7AH
2019 STA 2006 32H
201A 06H
201B 20H
201C HLT 76H