汇编分支程序设计 ARRAY存10数据,求最大数最小数存放在MAX和MIN中

分支程序设计

数组ARRAY存放10个字数据,求数组的最大数和最小数,并分别存放在MAX和MIN中

DATAS SEGMENT
            ARRAY DB 10 DUP(?)
            MIN  DB  '9'
            MAX   DB  '0'
DATAS ENDS

STACKS SEGMENT
STACKS ENDS

CODES SEGMENT
            ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
            MOV AX,DATAS
            MOV DS,AX

            MOV CX,10
            MOV DI,0
REST:    MOV AH,01H
            INT 21H
            MOV ARRAY[DI],AL
            INC DI
            LOOP REST
            
            MOV AL,MAX
            MOV AH,MIN
            MOV CX,10
            MOV DI,0

CONT:  
            CMP AH,ARRAY[DI]
            JBE NEXT1

            
            MOV AH,ARRAY[DI]
            MOV MIN,AH
            

            
NEXT1:  INC DI
             LOOP CONT

             MOV CX,10
             MOV DI,0

            


CONT2: CMP AL,ARRAY[DI]
             JAE NEXT2

             
             MOV AL,ARRAY[DI]
             MOV MAX,AL

NEXT2:  INC DI
             LOOP CONT2

             MOV CX,10
             MOV DI,0



AGAIN:MOV DL,ARRAY[DI]
            MOV AH,02H
            INT 21H
            INC DI
            LOOP AGAIN
  

            MOV DH,0
            mov AX,MIN
            mov DH,AX

            MOV AH,02H
            MOV DL,DH
            INT 21H



            MOV DH,0
            mov AX,MAX
            mov DH,AX

            
            MOV AH,02H
            MOV DL,DH
            INT 21H



            MOV AH,4CH
            INT 21H

CODES ENDS
            END START

你可能感兴趣的:(汇编语言)