37 Program to find smallest number from array in 8086 Microprocessor

Code:

; PROGRAM TO FIND SMALLEST NUMBER FROM ARRAY
.MODEL SMALL
.STACK 100H
.DATA
  ARR DB 05H,6H,08H,01H,00H
  SMALL DB ?
.CODE
  MOV AX , @DATA  ; INITIALIZING DATA SEGMENT
  MOV DS , AX

  MOV CX , 5      ; INITIALIZING LOOP COUNTER

  MOV SI , OFFSET ARR  ; STORING BASE ADDRESS OF ARRAY ARR
 
  MOV AL , [SI]

UP:
   INC SI

   CMP AL , [SI]

   JC NEXT
    MOV AL , [SI]
NEXT:
   LOOP UP

  MOV SMALL , AL  ; STORING RESULT IN HEX FORMAT

  MOV DL , AL
  ADD DL , 48

  MOV AH , 4CH    ; SOURCE ROUTINE FOR EXIT
  INT 21H

END




Ouput:




Previous
Next Post »