字符串比较的题目
字符串密码比较。若匹配则显示“MATCH”,否则显示“NOMATCH!,PROGRAM TERMINATED!”我的代码
程序代码:
;预留字符串口令,输入口令串与预留密码串比较。若匹配则显示“MATCH”,否则显示“NOMATCH!,PROGRAM TERMINATED!” DATAS SEGMENT str1 db '1$' str2 db 'please input a string:','$' len equ $-str1 str_d db 50,?,50 dup(?) mess1 db 0ah,0dh,'MATCH$' mess2 db 0ah,0dh,'NOMATCH!,PROGRAM TERMINATED!$' DATAS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS START: MOV AX,DATAS MOV DS,AX push ax mov dx,offset str2 mov ah,09h int 21h pop ax mov es,ax lea dx,str1 mov ah,0ah int 21h xor cx,cx mov cl,str_d cmp cx,len jne ms lea si,str1 lea di,str_d mad:mov al,ds:[si] mov bl,es:[di] cmp al,bl jne ms inc si inc di loop mad lea dx,mess1 mov ah,09h int 21h jmp exit ms: lea dx,mess2 mov ah,09h int 21h exit: MOV AH,4CH INT 21H CODES ENDS END START但 就算我输入正确的字符串 也得不到预期结果