Write an 8085 program to find the largest number from an array of 8-bit hexadecimal numbers - ChromeTechny
Home » Write an 8085 program to find the largest number from an array of 8-bit hexadecimal numbers

Write an 8085 program to find the largest number from an array of 8-bit hexadecimal numbers

In the last couple of programs, we saw how we can find out the larger and smaller number among two 8-bit numbers.

Fast forward, in this program, we are going to learn how we can find out the largest number from an array of 8-bit hexadecimal numbers.

Input:

For this program, we are going to use a total of seven memory locations, starting from 2000H.

In the 2000H memory location, we will store 06 which is the number of 8-bit numbers we will be using as a counter.

Next, from the 2001H memory location to 2006H memory locations we are going to store the 8-bit hexadecimal numbers.

The 8-bit hexadecimal numbers are CFH, 92H, EEH, F9H, A8H, and 99H.

Instructions:

LXI H, 2000H //using LXI we are going load HL register pair with 2000H memory location

MOV C, M // using MOV instruction, we will copy the content of 2000H ML to C register

INX H //using INX we will increment the HL register pair

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

Label2 DCR C //using DCR we will decrement the content of C register by 1

INX H //using INX we will increment the HL register pair to point the next successive memory location i.e. 20002H

CMP M //using CMP we will compare the content of the accumulator with the content of 2002H memory location

JNC Label1 //we will use JNC jump instruction to jump to DCR instruction when no carry is generated

MOV A, M //using MOV the content of memory location pointed by HL register pair will get copied to the accumulator

Label1 DCR C // using DCR we will decrement the content of C register by 1

JNZ Label2 //Jump No Zero instruction will keep on reducing DCR C until the content of C register becomes 0

STA 2007H// the result will be stored at 2007H memory location

HLT

 

Programming Details
Memory Location OPCODE Operand Label Hex Code
2008 LXI H, 2000H 21H
2009 00H
200A 20H
200B MOV C,M 4EH
200C INX H 23H
200D MOV A,M 7EH
200E DCR C Label2 0DH
200F INX H 23H
2010 CMP M BEH
2011 JNC label1 D2H
2012 0EH
2013 20H
2014 MOV A,M 7EH
2015 DCR C Label1 0D
2016 JNZ Label2 C2H
2017 15H
2018 20H
2019 STA 2007 32H
201A 07H
201B 20H
201C 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 *