天天看点

实验4 求最大值的程序设计

DATA SEGMENT
ORG 1000H
SZ1  DB 0A3H,0A8H,0B0H,9FH,9EH,0B1H,0AFH,0ADH,0A7H,0A8H
MAX  DB  ?
MIN  DB  ?
ORG 1012H 
SZ2  DB  ? 
DATA  ENDS

CODE  SEGMENT
ASSUME CS:CODE,DS:DATA
ST1: 
    MOV  AX,DATA                  
    MOV  DS,AX      
    CALL ZMAX        
    CALL ZMIN        
    CALL Z1        
    MOV  AH,4CH 
  INT   21H  

ZMAX PROC NEAR           
        LEA SI, SZ1 
        MOV CX,9
    MOV AX, [SI]
         
 LP2: INC SI
      CMP AL ,[SI]
      JAE LP1
    MOV AL ,[SI]
 LP1: 
      LOOP LP2
      MOV MAX,AL 
      RET
 ZMAX ENDP

 ZMIN PROC NEAR
        LEA SI, SZ1 
        MOV CX ,9
    MOV AL , [SI]    
  LP4: 
     INC SI 
     CMP AL ,[SI]
     JBE LP5
   MOV  AL,[SI] 
  LP5:  
      LOOP LP4
      MOV MIN ,AL 
  RET
  ZMIN ENDP
  
  Z1 PROC  NEAR 
       LEA SI, SZ1   
       MOV CX ,10
     MOV AX, 0
     MOV BX, 0

  
  ABC:
      MOV BL,[SI]
      ADD AX,BX
    INC SI
    LOOP ABC
    MOV BL,MAX 
    SUB AX,BX
    MOV BL ,MIN 
    SUB AX,BX
    MOV BL ,8
    DIV BL
    MOV SZ2 ,AL 
   RET
    Z1 ENDP  
CODE ENDS
END ST1      

继续阅读