PROGRAM NO.3
OBJECT:Write a program to find the greatest number from an array of 10 numbers.
INSTRUMENT REQUIRED: 8086 Microprocessor Trainer Kit.
PROGRAM:
MEMORY LOCATION | MACHINE CODE | OPCODE | OPERAND |
020B | B1 09 | MOV | CL,09H |
020D | BE 00 02 | MOV | SI,0200H |
0210 | 8A 04 | MOV | AL,[SI] |
0212 | 46 | L1 : INC | SI |
0213 | 3A 04 | CMP | AL,[SI] |
0215 | 73 02 | JNB L2 | |
0217 | 8A 04 | MOV | AL,[SI] |
0219 | FE C9 | L2 : DEC | CL |
021B | 75 F5 | JNZ L1 | |
021D | BF 0A 02 | MOV | DI,020AH |
0220 | 88 05 | MOV | [DI],AL |
0222 | F4 | HLT |
DESCRIPTION:
To solve the given objective, we have taken ten hexadecimal numbers in the memory locations from 0200H and 0209H. In order to find the greatest number amongst them we need to compare each number with the other. The greatest number will be stored in the memory location 020AH.
To solve the given objective, we have taken the following steps:
- Initially we initialize the counter register CL to 9 because the number of comparisons with any one number would be 9. In other words, it will compare 9 times.
- Move the source index register (SI) pointer to the location of the first number.
- Store the first number in the Al register using SI.
- Initiate a loop and compare each element with the element stored in AL while simultaneously decrementing counter CL.
- If the number is greater than that stored in AL then we store that number in AL else we do not change the value in AL.
- The above mentioned process goes on until CL becomes zero, at this point we have the greatest number in the AL register.
- Move the destination index (DI) pointer to point to the memory location where the result is to be stored.
- Finally move the result from the AL register to the destination using DI and Halt.
INPUT VALUE:
MEMORY LOCATION | VALUE |
0200H | A1 |
0201H | B1 |
0202H | C1 |
0203H | D1 |
0204H | E1 |
0205H | E2 |
0206H | E3 |
0207H | E4 |
0208H | E5 |
0209H | E6 |
020AH | 00 |
OUTPUT:
MEMORY LOCATION | VALUE |
020AH | E6 |
RESULT:The greatest of the 10 hexadecimal numbers is E6H, which gets stored in the memory location 020AH.
COMMENTS:
1. INC SI: The content of a specified 8-bit or 16-bit register or memory location(s) is incremented by one by this instruction.
2. CMP AL,[SI]: The compare instruction compares two specified operands. For comparison one operand is subtracted from the other.
3. JNC: It causes the program execution to jump to the label given in the instruction.
4. HLT: This instruction stops program execution. The processor stops fetching and executing instructions.
FLOWCHART:

Most Important Question for Exam
Binary Code Decimal
Stack
AX
16 bit
64 kb
Physical
40 Pin
Dual inline package
Base Pointer
Destination Index register
Source Index
Address Latche Enable
Non Mask able Interrupt
Code Segment
0000H to FFFFH
Properties of the programs being executed
Cache Memory
Cache
Main Memory
Cache Hits
Cache Misses
RESET Signal
BIU
Interrupts Request
Control Unit and ALU
Buses
Machine Language
PROM
DRAM
PROM
Related Link
- 8086 Instruction Hex Code
- Write a program to two add 16 bit Hexadecimal numbers without carry.
- Write a program to two add 16 bit Hexadecimal numbers with carry.
- Write a program to find the greatest number from an array of 10 numbers.
- Write a program to calculate the factorial of a number.
- Write a program to multiply two 16-bit numbers result should be greater than 16 bit.
- Write a program to input 5 numbers and arrange them in descending order.
- Write a program to convert the string data it’s Two’s complement form.
- Write a program to read 8 bit data from Port B. Complement this data & send it back to Port A of
- Write a program to move a block of data from one memory location to another. Input Value
- Write a program to find Gray code equivalent of a Binary number using Lookup Table.
- Microprocessor 8086 Video Play List