美文网首页
汇编实现求最大最小值

汇编实现求最大最小值

作者: lemonTreeTop | 来源:发表于2016-07-02 17:10 被阅读847次
    最大值最小流程图.png

    代码实现

    STACK1  SEGMENT STACK
             DW 256 DUP(?)
    STACK1  ENDS
    
    DATA SEGMENT
    NUM DB 05H,07H,5CH,03H,08H
    MAX DB ?
    MIN DB ?
    DATA ENDS
    
    CODE SEGMENT
    ASSUME CS:CODE,DS:DATA
    
    START:MOV AX,DATA
          MOV DS,AX
          MOV  CX,0004H
          MOV  SI,OFFSET NUM
          MOV BH,[SI]
          MOV BL,[SI]
          INC SI
    A1:MOV AL,[SI]
        INC SI
        CMP BH,AL   
        JAE A2
        MOV BH,AL
    A2:CMP BL,AL
        JBE A3
        MOV BL,AL
    A3:LOOP A1
    
       MOV SI,OFFSET MAX 
       MOV [SI],BH
       MOV [SI+1],BL
       CALL SHOW
       INC SI
       CALL SHOW
    
       MOV  AX,4C00H 
       INT  21H 
     
    SHOW    PROC NEAR
            MOV  AL,DS:[SI]    
            AND  AL,0F0H               
            MOV  CL,4             
            SHR  AL,CL
            CMP  AL,0AH                 
            JB   C2       
            ADD  AL,07H   
    C2:     ADD  AL,30H   
            MOV  DL,AL                  
            MOV  AH,02H
            INT  21H
            MOV  AL,DS:[SI]
            AND  AL,0FH                 
            CMP  AL,0AH
            JB   C3
           ADD  AL,07H
    C3:     ADD  AL,30H
            MOV  DL,AL                  
            MOV  AH,02H
            INT  21H
            RET 
     SHOW ENDP
     
    CODE ENDS
     
         END START
    

    相关文章

      网友评论

          本文标题:汇编实现求最大最小值

          本文链接:https://www.haomeiwen.com/subject/cnpqjttx.html