8086 program to find the min value in a given array
Problem – Write a program to find the min value in a given array in assembly 8086 microprocessor
Example –

Assumptions – Starting address of input array is 0500 and and store the result at address 0600
Algorithm –
- Assign value 500 in SI and 600 in DI
- Move the contents of [SI] in CL and increment SI by 1
- Assign the value 00 H to CH
- Move the content of [SI] in AL
- Decrease the value of CX by 1
- Increase the value of SI by 1
- Move the contents of [SI] in BL
- Compare the value of BL with AL
- Jump to step 11 if carry flag is set
- Move the contents of BL in AL
- Jump to step 6 until the value of CX becomes 0, and decrease CX by 1
- Move the contents of AL in [DI]
- Halt the program
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENTS |
|---|---|---|
| 0400 | MOV SI, 500 | SI <- 500 |
| 0403 | MOV DI, 600 | DI <- 600 |
| 0406 | MOV CL, [SI] | CL <- [SI] |
| 0408 | MOV CH, 00 | CH <- 00 |
| 040A | INC SI | SI <- SI+1 |
| 040B | MOV AL, [SI] | AL <- [SI] |
| 040D | DEC CX | CX <- CX-1 |
| 040E | INC SI | SI <- SI+1 |
| 040F | MOV BL, [SI] | BL <- [SI] |
| 0411 | CMP AL, BL | AL-BL |
| 0413 | JC 0417 | Jump if carry is 1 |
| 0415 | MOV AL, BL | AL <- BL |
| 0417 | LOOP 040E | Jump if CX not equal to 0 |
| 0419 | MOV [DI], AL | [DI] <- AL |
| 041B | HLT | End of the program |
Explanation –
- MOV SI, 500 assigns 500 to SI
- MOV DI, 600 assigns 600 to DI
- MOV CL, [SI] moves the content of [SI] to CL register
- MOV CH, 00 assign 00 to CH register
- INC SI increase the value SI by 1
- MOV AL, [SI] moves the content of [SI] to AL register
- DEC CX decrease the content of CX register by 1
- INC SI increase the value SI by 1
- MOV BL, [SI] moves the content of [SI] to BL register
- CMP AL, BL subtract the value of BL register from AL and it modify flag registers
- JC 0417 jump to 0417 address if carry flag is set
- MOV AL, BL moves the content of BL register to AL register
- LOOP 040E runs loop till CX not equal to Zero and decrease the value of CX by 1
- MOV [DI], AL moves the content of AL to [DI]
- HLT stops the execution of program
Recommended Posts:
- 8086 program to find sum of digits of 8 bit number
- 8086 program to find GCD of two numbers and print the GCD
- 8086 program to find sum of odd numbers in a given series
- 8086 program to find the factorial of a number
- 8086 program to find average of n numbers
- 8086 program to find sum of Even numbers in a given series
- 8086 program to find Square Root of a number
- 8086 program to sort an integer array in ascending order
- 8086 program to determine largest number in an array of n numbers
- 8086 program to sort an integer array in descending order
- 8086 program to determine modulus of first array elements corresponding to another array elements
- 8086 program to determine product of corresponding elements of two array elements
- 8086 program to determine cubes of numbers in an array of n numbers
- 8086 program to determine squares of numbers in an array of n numbers
- 8086 program to find the square root of a perfect square root number | Set-2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



