汇编:从键盘输入两个字符DLDS和NEWS。如果两个字符串相同输出YES,否则输出NO,得不到正确答案,求帮忙

DATASEGMENTDLDSDB30dup(?)NEWSDB30dup(?)STRDB"Inputastring:$"mess1DB"No$"mess2DB"Yes$"... DATA SEGMENT
DLDS DB 30 dup(?)
NEWS DB 30 dup(?)
STR DB "Input a string:$"
mess1 DB "No$"
mess2 DB "Yes$"
a DB 1 dup(?)
b DB 1 dup(?)
DATA ENDS

CODE SEGMENT
main proc far
assume ds:data,cs:code

start: push ds
xor ax,ax
push ax

mov ax,data
mov ds,ax

lea dx,STR
mov ah,9
int 21h
mov bx,offset DLDS
mov di,0

input: mov ah,01h
int 21h
cmp al,'#'
jz next
mov [bx+di],al
inc di
jmp input

next: lea dx,STR
mov ah,9
int 21h
mov bx,offset NEWS
mov si,0

again: mov ah,01h
int 21h
cmp al,'#'
jz then
mov [bx+si],al
inc si
jmp again

then: cmp si,di
jnz CON

CLD
mov cx,di
lea si,DLDS
lea di,news
repe cmpsb

cmp cx,0
jnz CON
lea dx,mess2
mov ah,9
int 21h
CON: lea dx,mess1
mov ah,9
int 21h

ret
MAIN endp
code ends
end start
展开
 我来答
gcbjoy
2017-09-25 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:92%
帮助的人:2362万
展开全部
        DATA  SEGMENT
        OLDS  DB        30 DUP(?)
        NEWS  DB        30 DUP(?)
        STRR  DB        13,10,"INPUT A STRING:$"
       MESS1  DB        13,10,"NO$"
       MESS2  DB        13,10,"YES$"
           A  DB        1 DUP(?)
           B  DB        1 DUP(?)
        DATA  ENDS

        CODE  SEGMENT
        MAIN  PROC      FAR
              ASSUME    DS:DATA,CS:CODE

      START:  PUSH      DS
              XOR       AX,AX
              PUSH      AX

              MOV       AX,DATA
              MOV       DS,AX
              MOV       ES,AX
            
              LEA       DX,STRR
              MOV       AH,9
              INT       21H
              MOV       BX,OFFSET OLDS
              MOV       DI,0

      INPUT:  MOV       AH,01H
              INT       21H
              CMP       AL,'#'
              JZ        NEXT
              MOV       [BX+DI],AL
              INC       DI
              JMP       INPUT

       NEXT:  LEA       DX,STRR
              MOV       AH,9
              INT       21H
              MOV       BX,OFFSET NEWS
              MOV       SI,0

      AGAIN:  MOV       AH,01H
              INT       21H
              CMP       AL,'#'
              JZ        THEN
              MOV       [BX+SI],AL
              INC       SI
              JMP       AGAIN

       THEN:  CMP       SI,DI
              JNZ       CON

              CLD
              MOV       CX,DI
              LEA       SI,OLDS
              LEA       DI,NEWS
              REPE      CMPSB

              CMP       CX,0
              JNZ       CON
              LEA       DX,MESS2
              MOV       AH,9
              INT       21H
              RET
              
        CON:  LEA       DX,MESS1
              MOV       AH,9
              INT       21H

              RET
        MAIN  ENDP
        CODE  ENDS
              END       START
追问
为什么需要多加21:mov es,ax以及65:ret
追答
因为DI寄存器
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式