Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Program to find the second highest number from a given array

Posted By: Ryan Bouchard     Category: Assembly Language     Views: 7166

Write a program to find the second highest number from a given array.

Code for Program to find the second highest number from a given array in Assembly Language


DATA SEGMENT
A DB 1,2,3,4,5,6,7,9,8
DATA ENDS
CODE SEGMENT
        ASSUME DS:DATA,CS:CODE
START:
      MOV AX,DATA
      MOV DS,AX
      LEA BX,A
      MOV AX,0000
      MOV CL,09
   L1:CMP AL,BYTE PTR[BX]
      JNC L2
      MOV AL,BYTE PTR[BX]
   L2:INC BX
      DEC CL
      CMP CL,00
      JNZ L1
      MOV DL,AL
      LEA BX,A
      MOV AX,0000
      MOV CL,09
   L3:CMP BYTE PTR[BX],DL
      JZ L4
      CMP AL,BYTE PTR[BX]
      JNC L4
      MOV AL,BYTE PTR[BX]
   L4:INC BX
      DEC CL
      CMP CL,00
      JNZ L3
     
      MOV AH,4CH
      INT 21H
CODE ENDS
END START

;OUTPUT:->
;-g cs:0037
;
;AX=0008  BX=0009  CX=0000  DX=0009  SP=0000  BP=0000  SI=0000  DI=000
;DS=0BAC  ES=0B9C  SS=0BAC  CS=0BAD  IP=0037   NV UP EI PL ZR NA PE NC
;0BAD:0037 B44C          MOV     AH,4C
  
Share: 



Ryan Bouchard
Ryan Bouchard author of Program to find the second highest number from a given array is from Montreal, Canada.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!