用汇编语言8086 统计以$结尾的字符串STRING的字符个数

 我来答
永恒pascal
2016-12-12 · TA获得超过4356个赞
知道大有可为答主
回答量:3902
采纳率:93%
帮助的人:659万
展开全部
code    segment
        assume cs:code
        org 100h
start:  jmp bbb
str1    db '1234567890123456789','$'
bbb:    push cs
        pop ds
        push cs
        pop es
        lea si,str1
        mov cx,3fffh
        cld
@1:
        lodsb
        cmp al,'$'
        je @2
        loop @1
@2:
        mov ax,3fffh
        sub ax,cx
        call dispaxs
        mov ah,4ch
        int 21h
;=========================================
     DISPAXS  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI
              PUSH      BP
              PUSH      DS
              PUSH      ES
              PUSHF
              PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              MOV       CX,6
              LEA       DI,DISPAXSS
   @DISPAXS:
              MOV       BYTE PTR [DI],32
              INC       DI
              LOOP      @DISPAXS
              PUSH      AX
              MOV       DL,32
              MOV       AH,2
              INT       21H
              POP       AX
              MOV       BYTE PTR NZS,0
              MOV       BYTE PTR SIGNS,0
              CMP       AX,0
              JGE       @DISPAXS0
              MOV       BYTE PTR SIGNS,1
              NEG       AX
  @DISPAXS0:
              PUSH      AX
              LEA    灶滑耐   SI,DIVARRS
              LEA       DI,DISPAXSS
              INC       DI
              MOV       CX,5
  @DISPAXS1:
              POP       AX
              MOV       DX,0
              MOV       BX,[SI]
              DIV       BX
              PUSH      DX
              CMP       AL,0
              JNE       @DISPAXS2
              CMP       BYTE PTR NZS,1
              JE        @DISPAXS2
              CMP       CX,1
              JE        @DISPAXS2
              MOV       DL,20H
              JMP       @DISPAXS3
  @DISPAXS2:
              ADD       AL,30H
              MOV       DL,AL
              MOV       BYTE PTR NZS,1
  @DISPAXS3:
              MOV       BYTE PTR[DI],DL
              INC       SI
              INC       SI
              INC       DI
              LOOP      @DISPAXS1
              POP       DX

              CMP       BYTE PTR SIGNS,1
              JNE       @DISPAXS6
              LEA       SI,DISPAXSS
              ADD       SI,5
  @DISPAXS4:
              CMP       BYTE PTR [SI],32
              JE        @DISPAXS5
              DEC       SI
              JMP       @DISPAXS4
  @DISPAXS5:
              MOV       BYTE PTR [SI],'-'
  @DISPAXS6:
              LEA       DX,DISPAXSS
              MOV       AH,9
              INT       21H
              POPF
              POP       ES
              POP       DS
              POP       BP
              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       BX
      让败        POP       AX
    隐春          RET
     DIVARRS  DW        10000,1000,100,10,1
         NZS  DB        0
       SIGNS  DB        0
    DISPAXSS  DB        32,32,32,32,32,32,'$'
     DISPAXS  ENDP
;==================================
    code    ends
    end start
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式