Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Embedded Systems

Find the minimum value in a given array | 8086 Microprocessor



Here, we are going to write an assembly language program in 8086 microprocessor to find the minimum value in a given range.
Submitted by Ayush Sharma, on November 08, 2018

Problem: Write a program to find the minimum value in a given array in assembly 8086 Microprocessor.

Assumptions: Starting address of input array is 0500 and stores the result at address 0600.

Algorithm:

  1. Assign value 500 in SI and 600 in DI
  2. Move the contents of [SI] in CL and increment SI by 1
  3. Assign the value 00 H to CH
  4. Move the content of [SI] in AL
  5. Decrease the value of CX by 1
  6. Increase the value of SI by 1
  7. Move the contents of [SI] in BL
  8. Compare the value of BL with AL
  9. Jump to step 11 if carry flag is set
  10. Move the contents of BL in AL
  11. Jump to step 6 until the value of CX becomes 0, and decrease CX by 1
  12. Move the contents of AL in [DI]
  13. Halt the program

Program:

ADDRESSMNEMONICSCOMMENTS
0400MOV SI, 500SI ← 500
0403MOV DI, 600DI ← 600
0406MOV CL, [SI] CL ← [SI]
0408MOV CH, 00 CH ← 00
040AINC SI SI ← SI+1
040BMOV AL, [SI] AL ← [SI]
040DDEC CX CX ← CX-1
040EINC SI SI ← SI+1
040FMOV BL, [SI] BL ← [SI]
0411CMP AL, BL AL-BL
0413JC 0417 Jump if carry is 1
0415MOV AL, BL AL ← BL
0417LOOP 040E Jump if CX not equal to 0
0419MOV [DI], AL [DI] ← AL
041BHLT End of the program

Explanation:

  1. MOV SI, 500 assigns 500 to SI
  2. MOV DI, 600 assigns 600 to DI
  3. MOV CL, [SI] moves the content of [SI] to CL register
  4. MOV CH, 00 assign 00 to CH register
  5. INC SI increase the value SI by 1
  6. MOV AL, [SI] moves the content of [SI] to AL register
  7. DEC CX decrease the content of CX register by 1
  8. INC SI increase the value SI by 1
  9. MOV BL, [SI] moves the content of [SI] to BL register
  10. CMP AL, BL subtract the value of BL register from AL and it modify flag registers
  11. JC 0417 jump to 0417 address if carry flag is set
  12. MOV AL, BL moves the content of BL register to AL register
  13. LOOP 040E runs loop till CX not equal to Zero and decrease the value of CX by 1
  14. MOV [DI], AL moves the content of AL to [DI]
  15. HLT stops the execution of program





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.