Write a 8085 program to find the smaller number among two 8-bit hexadecimal numbers - ChromeTechny
Home » Write a 8085 program to find the smaller number among two 8-bit hexadecimal numbers

Write a 8085 program to find the smaller number among two 8-bit hexadecimal numbers

In our previous program, we saw how we can find the largest number among two 8-bit hexadecimal numbers.

Now, in this program, we are going to look at how we can find out the smaller number among two 8-bit hexadecimal numbers.

Input:

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

JC 200B // we will Jump Carry control instruction so that when  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 JC 200E DH
200B 0EH
200C 20H
200D MOV A,B 78H
200E INX H 23H
200F MOV M,A 77H
2010 HLT 76H

About the author

Ayan

Add Comment

Click here to post a comment

Your email address will not be published. Required fields are marked *