急急急!微机原理汇编语言求原程序,题目如下:

2024年11月15日 01:53
有1个网友回答
网友(1):

        CODE  SEGMENT
              ASSUME    CS:CODE

        BUFF  DB        100 DUP(?)
           X  DW        0
           Y  DW        0
           Z  DW        0

      START:  PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              LEA       DI,BUFF
              MOV       AL,1
              MOV       CX,100
              CLD
         @1:
              STOSB
              INC       AL
              LOOP      @1

              LEA       SI,BUFF
              MOV       CX,100
              CLD
         @2:
              LODSB
              CBW
              ADD       X,AX
              LOOP      @2
              
              MOV       AX,X
              MOV       BX,10
              CALL      DSPAX
              

              LEA       SI,BUFF
              MOV       CX,100
              CLD
         @3:
              LODSB
              CBW
              MOV       BX,AX
              CALL      F
              CMP       AX,0
              JE        @4
              INC       WORD PTR Y
              ADD       Z,BX
         @4:
              LOOP      @3
              
              MOV       AX,Y
              MOV       BX,10
              CALL      DSPAX
              MOV       AX,Y
              MOV       BX,2
              CALL      DSPAX

              MOV       AH,4CH
              INT       21H
 ;====================================
; 要判断的数放入ax中
; ax返回1时表示是素数
; ax返回0时表示是合数
           F  PROC      NEAR
              PUSH      BX
              PUSH      DX
              JMP       F1
         @@X  DW        ?
        @@X2  DW        ?
         F1:  CMP       AX,1
              JZ        F2
              CMP       AX,2
              JZ        F11
              CMP       AX,3
              JZ        F11
              MOV       @@X,AX
              SHR       AX,1
              MOV       @@X2,AX
              MOV       BX,2
        FLP:  MOV       DX,0
              MOV       AX,@@X
              DIV       BX
              CMP       DX,0
              JZ        F2
              INC       BX
              CMP       BX,@@X2
              JBE       FLP
        F11:  MOV       AX,1
              POP       DX
              POP       BX
              RET
         F2:  MOV       AX,0
              POP       DX
              POP       BX
              RET
           F  ENDP
;=============================== 
       DSPAX  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSHF
              XOR       CX,CX
              ; MOV       BX,2        
    @DSPAX1:
              XOR       DX,DX
              DIV       BX
              INC       CX
              OR        DX,30H
              PUSH      DX
              CMP       AX,0
              JNE       @DSPAX1
              MOV       AH,2
   @DISPAX2:
              POP       DX
              INT       21H
              LOOP      @DISPAX2
              MOV       DL,32
              INT       21H
              POPF
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
       DSPAX  ENDP
;==================================    
        CODE  ENDS
              END       START