详细解释一段简单的汇编语言程序,比较两个字符串内容的
DATASEGMENTSTR1DB100LEN1DB?DB100DUP(?)STR2DB100LEN2DB?DB100DUP(?)INFO1DB0AH,0DH,'inpu...
DATASEGMENT
STR1DB 100
LEN1DB ?
DB 100 DUP(?)
STR2DB 100
LEN2DB ?
DB 100 DUP(?)
INFO1DB 0AH,0DH,'input string1:','$'
INFO2DB 0AH,0DH,'input string2:','$'
INFO3DB 0AH,0DH,'string1=string2:'
JUDGDB 20H,20H,20H,'$'
DATAENDS
STACKSEGMENT STACK
DB 200 DUP(0)
STACKENDS
CODESEGMENT
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
具体一些,每一行或者一段的意思,主要是老师要提问,需要讲解,刚开始学。谢谢了~ 展开
STR1DB 100
LEN1DB ?
DB 100 DUP(?)
STR2DB 100
LEN2DB ?
DB 100 DUP(?)
INFO1DB 0AH,0DH,'input string1:','$'
INFO2DB 0AH,0DH,'input string2:','$'
INFO3DB 0AH,0DH,'string1=string2:'
JUDGDB 20H,20H,20H,'$'
DATAENDS
STACKSEGMENT STACK
DB 200 DUP(0)
STACKENDS
CODESEGMENT
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
具体一些,每一行或者一段的意思,主要是老师要提问,需要讲解,刚开始学。谢谢了~ 展开
展开全部
DATASEGMENT
STR1DB 100
LEN1DB ?
DB 100 DUP(?)
STR2DB 100
LEN2DB ?
DB 100 DUP(?)
INFO1DB 0AH,0DH,'input string1:','$'
INFO2DB 0AH,0DH,'input string2:','$'
INFO3DB 0AH,0DH,'string1=string2:'
JUDGDB 20H,20H,20H,'$'
DATAENDS
STACKSEGMENT STACK
DB 200 DUP(0)
STACKENDS
CODESEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:MOV AX,DATA
MOV DS,AX;***输入字符串****
LEA DX,INFO1 ;显示INFO1
MOV AH,09H
INT 21H
LEA DX,STR1
MOV AH,0AH;输入字符串1
INT 21H;
LEA DX,INFO2 ;显示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 ;不相等跳到NO
MOV CH,0 ;相等时比较两个字符串的每个字符是否相等,不相等跳到NO
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' ;相等时写入JUDG YES结束 输出显示
MOV JUDG+1,'E'
MOV JUDG+2,'S'
JMP FINI
NO:MOV JUDG,'N' ;不相等时写入JUDG NO 结束 输出显示
MOV JUDG+1,'O';***输出判断结果***
FINI:LEA DX,INFO3
MOV AH,09H
INT 21H;输出判断结果
;***程序结束***
MOV AH,4CH;程序结束
INT 21H
CODE ENDS
END START
STR1DB 100
LEN1DB ?
DB 100 DUP(?)
STR2DB 100
LEN2DB ?
DB 100 DUP(?)
INFO1DB 0AH,0DH,'input string1:','$'
INFO2DB 0AH,0DH,'input string2:','$'
INFO3DB 0AH,0DH,'string1=string2:'
JUDGDB 20H,20H,20H,'$'
DATAENDS
STACKSEGMENT STACK
DB 200 DUP(0)
STACKENDS
CODESEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:MOV AX,DATA
MOV DS,AX;***输入字符串****
LEA DX,INFO1 ;显示INFO1
MOV AH,09H
INT 21H
LEA DX,STR1
MOV AH,0AH;输入字符串1
INT 21H;
LEA DX,INFO2 ;显示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 ;不相等跳到NO
MOV CH,0 ;相等时比较两个字符串的每个字符是否相等,不相等跳到NO
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' ;相等时写入JUDG YES结束 输出显示
MOV JUDG+1,'E'
MOV JUDG+2,'S'
JMP FINI
NO:MOV JUDG,'N' ;不相等时写入JUDG NO 结束 输出显示
MOV JUDG+1,'O';***输出判断结果***
FINI:LEA DX,INFO3
MOV AH,09H
INT 21H;输出判断结果
;***程序结束***
MOV AH,4CH;程序结束
INT 21H
CODE ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询