In the last program, we saw how we can perform 2’s complement on an 8-bit and 16-bit hexadecimal numbers.

In this program, we are going give a look at how we can find the larger number among two 8-bit hexadecimal number.

Now as far as addressing mode is concerned, for this program, we are going to use immediate addressing mode.

Input:

For this program, we are going to need three memory locations, we are going to start from the 2000H memory location.

In the 2000H memory location, we are going to store the first 8-bit number i.e. 25H, and in the 2001H memory location, we are going to store our 2nd 8-bit number i.e. 15H.

And last but not the least, in 2002H ML, we are going to store the result.

Instruction:

LXI H,2000H //using LXI instruction, we will point HL register pair to 2000H memory location

MOV A, M //using MOV instruction we will copy the content of 2000H to the accumulator

INX H //using INX we will increment the memory location to 2001H memory location

MOV  B, M //once again we will use MOV instruction to copy the content of 2001H memory location to B register

CMP B //using CMP we will compare the content of accumulator with the content of B register

JNC 200EH//we will Jump No Carry control instruction so that when no carry is generated then it will jump to 200E memory location

MOV A, B //if carry is generated then using MOV we will copy the content of B register to the accumulator

INX H// using INX H we will point the HL register to 2002H memory location

MOV M, A //we will copy the content of accumulator to 2002H memory location

HLT

 

Programming Details
Memory Location OPCODE Operand Label Hex Code
2003 LXH H, 2000H 21H
2004 00H
2005 20H
2006 MOV A,M 7EH
2007 INX H 23H
2008 MOV B,M 46H
2009 CMP B B8H
200A JNC 200E D2H
200B 0EH
200C 20H
200D MOV A,B 78H
200E INX H 23H
200F MOV M,A 77H
2010 HLT 76H