汇编实验,比较两个字符串是否相同并输出相关提示语,编译错误
Win7下用64为masm编译器编译:Q.asm(10):errorA2008:syntaxerror:SEGMENTQ.asm(11):errorA2008:synta...
Win7下用64为masm编译器编译:
Q.asm(10) : error A2008:syntax error : SEGMENT
Q.asm(11) : error A2008:syntax error : CS
Q.asm(12) : error A2034:must be in segment block
Q.asm(13) : error A2034:must be in segment block
求解决~~
代码:
http://hi.baidu.com/846738496/item/1e2c7c61df57e4046995e62c 展开
Q.asm(10) : error A2008:syntax error : SEGMENT
Q.asm(11) : error A2008:syntax error : CS
Q.asm(12) : error A2034:must be in segment block
Q.asm(13) : error A2034:must be in segment block
求解决~~
代码:
http://hi.baidu.com/846738496/item/1e2c7c61df57e4046995e62c 展开
展开全部
已经调好:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
WORD1 DB 'Please Input The String1',0dh,0ah,'$' ;string1的导语
WORD2 DB 'Please Input The String2',0dh,0ah,'$' ;string2的导语
S1 DB 125, ?, 125 DUP(?)
S2 DB 125, ?, 125 DUP(?)
JIE1 DB 'MATCH', 0DH, 0AH, '$'
JIE2 DB 'NO MATCH', 0DH, 0AH, '$'
CSL DB 0DH, 0AH, '$'
DATA ENDS
CODE SEGMENT 'CODE'
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AH, 9
LEA DX, WORD1
INT 21H
MOV AH, 10
LEA DX, S1
INT 21H
MOV AH, 9
LEA DX, CSL
INT 21H
MOV AH, 9
LEA DX, WORD2
INT 21H
MOV AH, 10
LEA DX, S2
INT 21H
MOV AH, 9
LEA DX, CSL
INT 21H
CMPSS:
CLD
MOV CL, S1 + 1
CMP CL, S2 + 1 ;比较两者长度
JNZ NMATCH ;不同则转
MOV CH, 0 ;CX=长度
LEA SI, S1 + 2 ;字符串起始地址
LEA DI, S2 + 2
REPZ CMPSB
JZ MATCH
NMATCH:
LEA DX, JIE2
JMP EX
MATCH:
LEA DX, JIE1
EX:
MOV AH, 9
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
WORD1 DB 'Please Input The String1',0dh,0ah,'$' ;string1的导语
WORD2 DB 'Please Input The String2',0dh,0ah,'$' ;string2的导语
S1 DB 125, ?, 125 DUP(?)
S2 DB 125, ?, 125 DUP(?)
JIE1 DB 'MATCH', 0DH, 0AH, '$'
JIE2 DB 'NO MATCH', 0DH, 0AH, '$'
CSL DB 0DH, 0AH, '$'
DATA ENDS
CODE SEGMENT 'CODE'
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AH, 9
LEA DX, WORD1
INT 21H
MOV AH, 10
LEA DX, S1
INT 21H
MOV AH, 9
LEA DX, CSL
INT 21H
MOV AH, 9
LEA DX, WORD2
INT 21H
MOV AH, 10
LEA DX, S2
INT 21H
MOV AH, 9
LEA DX, CSL
INT 21H
CMPSS:
CLD
MOV CL, S1 + 1
CMP CL, S2 + 1 ;比较两者长度
JNZ NMATCH ;不同则转
MOV CH, 0 ;CX=长度
LEA SI, S1 + 2 ;字符串起始地址
LEA DI, S2 + 2
REPZ CMPSB
JZ MATCH
NMATCH:
LEA DX, JIE2
JMP EX
MATCH:
LEA DX, JIE1
EX:
MOV AH, 9
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询