汇编语言:比较两个输入的字符串是否完全相同,是则显示YES,否则显示NO。
展开全部
DATA SEGMENT
STR1 DB 100
LEN1 DB ?
DB 100 DUP(?)
STR2 DB 100
LEN2 DB ?
DB 100 DUP(?)
INFO1 DB 0AH,0DH,'input string1:','$'
INFO2 DB 0AH,0DH,'input string2:','$'
INFO3 DB 0AH,0DH,'string1=string2:'
JUDG DB 20H,20H,20H,'$'
DATA ENDS
STACK SEGMENT STACK
DB 200 DUP(0)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
;***输入字符串****
LEA DX,INFO1
MOV AH,09H
INT 21H
LEA DX,STR1
MOV AH,0AH ;输入字符串1
INT 21H
LEA DX,INFO2
MOV AH,09H
INT 21H
LEA DX,STR2
MOV AH,0AH ;输入字符串2
INT 21H
;***判断字符串***
MOV AL,LEN1 ;字符串1的长度
MOV AH,LEN2 ;字符串2的长度
CMP AH,AL
JNZ NO
MOV CH,0
MOV CL,AL
MOV SI,0
MOV DI,0
NEXT: INC SI
INC DI
MOV AH,LEN1[SI]
CMP AH,LEN2[DI]
JNZ NO
LOOP NEXT
MOV JUDG,'Y'
MOV JUDG+1,'E'
MOV JUDG+2,'S'
JMP FINI
NO: MOV JUDG,'N'
MOV JUDG+1,'O'
;***输出判断结果***
FINI: LEA DX,INFO3
MOV AH,09H
INT 21H ;输出判断结果
;***程序结束***
MOV AH,4CH ;程序结束
INT 21H
CODE ENDS
END START
STR1 DB 100
LEN1 DB ?
DB 100 DUP(?)
STR2 DB 100
LEN2 DB ?
DB 100 DUP(?)
INFO1 DB 0AH,0DH,'input string1:','$'
INFO2 DB 0AH,0DH,'input string2:','$'
INFO3 DB 0AH,0DH,'string1=string2:'
JUDG DB 20H,20H,20H,'$'
DATA ENDS
STACK SEGMENT STACK
DB 200 DUP(0)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
;***输入字符串****
LEA DX,INFO1
MOV AH,09H
INT 21H
LEA DX,STR1
MOV AH,0AH ;输入字符串1
INT 21H
LEA DX,INFO2
MOV AH,09H
INT 21H
LEA DX,STR2
MOV AH,0AH ;输入字符串2
INT 21H
;***判断字符串***
MOV AL,LEN1 ;字符串1的长度
MOV AH,LEN2 ;字符串2的长度
CMP AH,AL
JNZ NO
MOV CH,0
MOV CL,AL
MOV SI,0
MOV DI,0
NEXT: INC SI
INC DI
MOV AH,LEN1[SI]
CMP AH,LEN2[DI]
JNZ NO
LOOP NEXT
MOV JUDG,'Y'
MOV JUDG+1,'E'
MOV JUDG+2,'S'
JMP FINI
NO: MOV JUDG,'N'
MOV JUDG+1,'O'
;***输出判断结果***
FINI: LEA DX,INFO3
MOV AH,09H
INT 21H ;输出判断结果
;***程序结束***
MOV AH,4CH ;程序结束
INT 21H
CODE ENDS
END START
追问
设计说明会不-,-?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询