简易密码问题,有点小问题,请大家帮忙看看!
datasegment
dectadb '123456 '
sourcedb6 dup(?)
string1db 'welcome! ',13,10, '$ '
string2db 'error! ',13,10, '$ '
dataends
codesegment
assumecs:code,ds:data
start:
movax,data
movds,ax
movcx,6;set the number of code
movsi,0
con:;intput the code;从键盘输入密码
movah,07h
int21h
movsource[si],al
movdl, '* '
movah,02h
int21h
incsi
loopcon
;compare the source and destination(比较)(方法一)
;leasi,source
;leadi,decta
;movcx,6
;repecmpsb
;jcxzyes
movcx,6;compare the strings;(方法2)
movsi,0
movdi,0
comp:
movbl,source[si]
movdl,decta[di]
cmpdl,bl
jnzno
incsi
incdi
deccx
jnzcomp
yes:
movdx,offset string1
movah,9
int21h
jmpexit
no:
movdx,offset string2
movah,9
int21h
exit:
movax,4c00h
int21h
codeends
endstart
为什么用串指令进行比较的时候程序运行就有错误?
[解决办法]
....
start:
mov ax,data
mov ds,ax
mov es, ax ;*+ 加上这个指令
....
repe cmpsb
jcxz yes
jmp no ;*+ 下面紧接着是 yes: 标号, 所以, 要有该指令的
....