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.

Input:

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.

Program:

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

HLT

Programming Details
Memory Location OPCODE Operand Label Hex Code
2003 LXI H, 2000 21H
2004 00H
2005 20H
2006 MOV A,M 7EH
2007 ANI 0F E6H
2008 0FH
2009 STA 2001 32H
200A 01H
200B 20H
200C LDA 2000 3AH
200D 00H
200E 20H
200F ANI F0 E6H
2010 F0H
2011 STA 2002 32H
2012 02H
2013 20H
2014 HLT 76H