汇编程序求助!!!比较字符串
这段代码是用来比较BUF1和BUF2两个字符串的可是不管匹不匹配都是nomatch!DATASSEGMENTSTRING1DB'pleaseinputastring1:$...
这段代码是用来比较BUF1和BUF2两个字符串的 可是不管匹不匹配都是nomatch!
DATAS SEGMENT
STRING1 DB 'please input a string1:$'
STRING2 DB 'please input a string2:$'
STRING3 DB 'MATCH!$'
STRING4 DB 'NO MATCH!$'
BUF1 DB 20 ,?, 20 DUP (?);;缓冲区1,放置字符串1
BUF2 DB 20 ,?, 20 DUP (?);;缓冲区2. 放置字符串2
CRLF DB 0AH,0DH,"$";此处输入数据段代码
DATAS ENDS
STACKS SEGMENT STACK
DB 200 DUP(?) ;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START: MOV AX,DATAS
MOV DS,AX;此处输入代码段代码
MOV AX,STACKS
MOV SS,AX
LEA DX,STRING1;;显示提示语1
MOV AH,9
INT 21H
MOV AH,0AH
LEA DX,BUF1;;输入字符串1
INT 21H
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,STRING2;;显示提示语2
MOV AH,9
INT 21H
MOV AH,0AH
LEA DX,BUF2;;输入字符串2
INT 21H
LEA DX,CRLF;;回车,换行
MOV AH,09H
INT 21H
LEA SI,BUF1+2
LEA DI,BUF2+2
MOV CX,5
NEXT:CMP SI,DI
JNZ EED
INC SI
INC DI
DEC CX
JNZ NEXT
LEA DX,STRING3
MOV AH,09H
INT 21H
JMP ESS
EED: LEA DX,STRING4
MOV AH,09H
INT 21H
ESS:
MOV AH,4CH
INT 21H
CODES ENDS
END START 展开
DATAS SEGMENT
STRING1 DB 'please input a string1:$'
STRING2 DB 'please input a string2:$'
STRING3 DB 'MATCH!$'
STRING4 DB 'NO MATCH!$'
BUF1 DB 20 ,?, 20 DUP (?);;缓冲区1,放置字符串1
BUF2 DB 20 ,?, 20 DUP (?);;缓冲区2. 放置字符串2
CRLF DB 0AH,0DH,"$";此处输入数据段代码
DATAS ENDS
STACKS SEGMENT STACK
DB 200 DUP(?) ;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START: MOV AX,DATAS
MOV DS,AX;此处输入代码段代码
MOV AX,STACKS
MOV SS,AX
LEA DX,STRING1;;显示提示语1
MOV AH,9
INT 21H
MOV AH,0AH
LEA DX,BUF1;;输入字符串1
INT 21H
LEA DX,CRLF
MOV AH,9
INT 21H
LEA DX,STRING2;;显示提示语2
MOV AH,9
INT 21H
MOV AH,0AH
LEA DX,BUF2;;输入字符串2
INT 21H
LEA DX,CRLF;;回车,换行
MOV AH,09H
INT 21H
LEA SI,BUF1+2
LEA DI,BUF2+2
MOV CX,5
NEXT:CMP SI,DI
JNZ EED
INC SI
INC DI
DEC CX
JNZ NEXT
LEA DX,STRING3
MOV AH,09H
INT 21H
JMP ESS
EED: LEA DX,STRING4
MOV AH,09H
INT 21H
ESS:
MOV AH,4CH
INT 21H
CODES ENDS
END START 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询