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