汇编语言编程计算S=1^2+2^2+3^2+4^2+……+N^2,直到N^2大于81为止

 我来答
永恒pascal
2017-04-08 · TA获得超过4357个赞
知道大有可为答主
回答量:3902
采纳率:93%
帮助的人:666万
展开全部
        CODE  SEGMENT
              ASSUME    CS:CODE
              ORG       100H
      START:  PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              MOV       SI,1
              MOV       DI,0
         @1:
              MOV       AX,SI
              MOV       BX,SI
              MUL       BL
              CMP       AX,81
              JA        @2
              ADD       DI,AX
              INC       SI
              JMP       @1

         @2:
              MOV       AX,DI
              CALL      DISPAX
              
              MOV       AH,4CH
              INT       21H

; 将要显示的无符号数置于 ax 中 
      DISPAX  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI
              PUSH      BP
              PUSHF
              PUSH      DS
              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
              POP       DS
              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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式