In the last program, we learned how we can find the largest number from an array of 8-bit hexadecimal numbers.
Moving forward, in this post, we are going to learn how we can find out the smallest number from an array of 8-bit hexadecimal numbers.
Like the last program, in this program, we are also going take 6 8-bit hexadecimal numbers. And this program also is very much identical to the last program there will be one single change.
We are going to use a total of seven memory locations, starting from 2000H like we did in our last program.
In the 2000H memory location, we will store 06 which is the number of 8-bit numbers we will be using.
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.
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
JC Label1 //we will use JC jump instruction to jump to DCR instruction when 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
|Memory Location||OPCODE||Operand||Label||Hex Code|