So far in this program series, we have used Arithmetic and Data Transfer instruction, but in this program, we will be using Logical instruction.
Now, if you are not familiar with Logical instruction then you won’t be able to understand this kind of programs.
As you can see from the heading, in this program we are going to separate a given 8-bit hexadecimal number into two nibbles.
We are not going to use any kind of specific addressing mode.
For this program, we are going to need only three memory locations; the first memory location i.e. 2000H will contain the 8-bit number, 2001H will contain one nibble and 2002H will contain the other nibble.
LXI H, 2000H //using LXI instruction we will point the HL register to 2000H memory location
MOV A,M // we’ll now move the content of 2000H memory location into the accumulator
ANI OF //now we will perform AND operation with the content of accumulator and OFH
STA 2001H //using STA we will now store the result in 2001H memory location
LDA 2000H //using LDA we’ll load the content of 2000H in the accumulator
ANI F0 //once again we will perform AND operation to separate another bit
STA 2002H //now we will store the content of accumulator in 2002H memory location
|Memory Location||OPCODE||Operand||Label||Hex Code|