8086汇编语言求数组中的最大值的程序,谁会?急求……⊙﹏⊙

如题所述

        CODE  SEGMENT
              ASSUME    CS:CODE
              ORG       100H
      START:
              PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              CALL      INPUTNUM
              LEA       SI,ARRAY
              MOV       CX,[NUM]
              MOV       AX,0
              MOV       [NUM_MAX],AX
     @MAIN0:  MOV       AX,WORD PTR [SI]
              CMP       [NUM_MAX],AX
              JNC       @MAIN1      ; 无符号数用 jnc,有符号数用 jl
              MOV       [NUM_MAX],AX
     @MAIN1:  INC       SI
              INC       SI
              LOOP      @MAIN0
              LEA       DX,LFCR
              MOV       AH,9
              INT       21H
              MOV       AX,[NUM_MAX]
              CALL      DISPAX
              MOV       AH,4CH
              INT       21H
     NUM_MAX  DW        ?
        LFCR  DB        10,13,'$'
 ;==============================================================
 ; 键盘输入数值数组子程序(数组名为array,元素个数存放在num中)
    INPUTNUM  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI
              PUSH      BP
              PUSHF
              ; 输入的字数据以一个空格分隔,以回车符结束输入
              LEA       DI,ARRAY    ;将数组第一个元素的有效地址置入DI
              MOV       WORD PTR[NUM],0
       STIN:
              MOV       AX,0
              PUSH      AX
     AGAIN1:
              MOV       AH,1
              INT       21H
              MOV       BYTE PTR[CHAR],AL
              CMP       AL,13
              JE        LINE0
              CMP       AL,' '
              JE        LINE0
              SUB       AL,30H
              MOV       AH,0
              MOV       SI,AX
              POP       AX
              MOV       CL,10
              MOV       CH,0
              MUL       CX
              ADD       AX,SI
              PUSH      AX
              JMP       AGAIN1
      LINE0:
              POP       AX
              MOV       WORD PTR[DI],AX
              INC       WORD PTR[NUM]
              CMP       BYTE PTR[CHAR],13
              JE        STINEND
              INC       DI
              INC       DI
              JMP       STIN
    STINEND:
              POPF
              POP       BP
              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
       ARRAY  DW        500 DUP(0)
         NUM  DW        0
        CHAR  DB        ?
    INPUTNUM  ENDP
              

    ; 将要显示的无符号数置于 ax 中 
      DISPAX  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI
              PUSH      BP
              PUSHF
              ;================
              PUSH      CS
              POP       DS
              MOV       BYTE PTR NZ,0
              PUSH      AX
              LEA       SI,DIVARR
              MOV       CX,5
         @1:
              POP       AX
              MOV       DX,0
              MOV       BX,[SI]
              DIV       BX
              PUSH      DX
              CMP       AL,0
              JNE       @2
              CMP       BYTE PTR NZ,1
              JE        @2
              CMP       CX,1
              JE        @2
              MOV       DL,20H
              JMP       @3
         @2:
              ADD       AL,30H
              MOV       DL,AL
              MOV       BYTE PTR NZ,1
         @3:
              MOV       AH,2
              INT       21H
              INC       SI
              INC       SI
              LOOP      @1
              POP       DX
              ;=============
              MOV       DL,32
              MOV       AH,2
              INT       21H
              POPF
              POP       BP
              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
      DIVARR  DW        10000,1000,100,10,1
          NZ  DB        0
      DISPAX  ENDP
    

        CODE  ENDS
              END       START

追问

谢谢!

温馨提示:内容为网友见解,仅供参考
无其他回答

8086汇编语言求数组中的最大值的程序,谁会?急求……⊙﹏⊙
CODE SEGMENT ASSUME CS:CODE ORG 100H START: PUSH CS POP DS PUSH CS POP ES CALL INPUTNUM LEA SI,ARRAY MOV CX,[NUM] MOV AX,0

汇编语言
38.设有50个无符号8位二进制数,存放在8031单片机内部RAM以BOFFER为首地址的连续单元中,试编制将其中最小数存放到内部RAM的MIN单元的程序并画出相应的流程。39.设有一字符串存放在8031单片机内部RAM以START为首址的连续单元中,字符串是以回车(回车CR=0DH)结束,试编制将该字符串中最后一个非空格字符的地址送内部...

求计算机大神解答:输入100个整数,求其中的最大值和最小值并输出,使用传...
C语言程序 include "stdio.h"main(){ int min,max;int i,temp;scanf("%d",max);scanf("%d",min);if(max<min){ temp=max;max=min;min=temp;} for(i=2;i<100;i++){ scanf("%d",temp);if(temp>max)max=temp;if(temp<min)min=temp;} Printf("Max Number=%d,Min Number=%d\\n...

相似回答