In the past, you have come across programs in which either we have found out the largest or the smallest number.
So basically the output will display both the smallest and the largest number.
For this program, we are going to use four successive memory locations starting from 2000H to 2003H. In 2000H and 2001H ML, we are going to store EFH and E9H 8-bit hexadecimal numbers and 2002H and 2003H will be kept reserved to store the smallest and the largest number.
LXI H, 2000H //using LXI we will load the content of 2000H ML in HL register pair
MOV A, H // the content of 2000H ML pointed by HL register will get copied to the accumulator
INX H //HL register pair will be incremented by one
CMP M //the content of the accumulator will be compared with the content of 2001H ML
JNC Label1 //JNC instruction is used in case the value stored accumulator is larger then it will get stored in 2003H memory location
MOV A, M //the content of 2001H ML will be copied to the accumulator
Label STA 2002// the content of accumulator will be copied to 2002H memory location
JC Label2 // if the carry flag is set then the JC jump instruction will work
MOV A, M //content of 2001H will get copied to the accumulator
Label2 STA 2003 //the content of accumulator gets copied to 2003 memory location
|Memory Location||OPCODE||Operand||Label||Hex Code|