DATAS SEGMENT
source1 db 50 dup(?) ; 寄存第一个串
source2 db 50 dup(?) ; 寄存第二个串
title1 db Please input the first string:,0dh,0ah,$
title2 db Please input the second string:,0dh,0ah,$
ans db match,0dh,0ah,$
ans1 db no match,0dh,0ah,$
DATAS ENDS
STACKS SEGMENT
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov dx,offset title1;输出昂首
mov ah,09h ;输出字符串用09
int 21h
mov cl,50
mov si,0
again:
mov ah,01h
int 21h
cmp al,0dh
jz two
mov source1[si],al
inc si
dec cl
jnz again ;将第一个串搞定
two:
mov dx,offset title2;输出第二个昂首
mov ah,09h
int 21h
mov cl,50
mov si,0
again1:
mov ah,01h
int 21h
cmp al,0dh
jz main
mov source2[si],al
inc si
dec cl
jnz again1;这儿以上部分是给两个字符串赋值,一下部分是比较。
main:
mov si,0
mov cx,6
again2:mov al,source2[si]
cmp source1[si],al
jnz nomatch
incsi
dec cx
jnz again2
cmpcx,0
jz match
nomatch:mov dx,offset ans1
mov ah,09h
int 21h
jmp over
match: mov dx,offset ans
mov ah,09h
int 21h
over: MOV AH,4CH
INT 21H
CODES ENDS
END START
; MADE BY WQ
这儿是完善版的程序:http://www.51hei.com/mcu/2469.html