MOV AH,02H(mov ah 09h)
INT 21H
例子:
DATA SEGMENT
BUF1 DB 'EEEEEENENEN.'
LEN1=$-BUF1
BUF2 DB 'EEEEEENANAN!'
LEN2=$-BUF2
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:MOV AX, DATA
MOV DS,AX
LEA SI,BUF1
;MOV CX,LEN1
;CALL CMMP
LEA DI,BUF2
MOV CX,LEN1
CALL CMMP
MOV AH,4CH
INT 21H
CMMP PROC NEAR;子程序
;利用主程序调用子程序,比较BUF1和BUF2缓冲区中不相等的字符,并将不相等的字符显示出来.
L:MOV DL,[SI]
CMP DL,[DI]
JZ L1
MOV AL,'Y'
MOV [SI],AL
MOV AH,02H;单个字符的输出
INT 21H
L1:INC SI
INC DI
LOOP L
RET
CMMP ENDP
CODE ENDS
END START
DATA SEGMENT
BUF1 DB 'DSSSSSSSNNNs',0AH,0DH,'$'
LEN1=$-BUF1
BUF2 DB 'WERTYUGJINNNN!','$ '
LEN2=$-BUF2
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:MOV AX, DATA
MOV DS,AX
LEA SI,BUF1
MOV CX,LEN1
CALL CMMP
LEA SI,BUF2
MOV CX,LEN2
CALL CMMP
MOV AH,4CH
INT 21H
CMMP PROC
;子程序搜索指定字符缓冲区中是否有N,如果有用Y替代。调用子程序将BUF1,BUF2,BUF3中的N全部用Y替代.
MOV DX,SI
L:CMP BYTE PTR[SI], 'N'
JNZ L1
MOV AL,'Y'
MOV [SI],AL
L1:INC SI
LOOP L
MOV AH,09H;输出字符串"DSSSSSSSYYYs"和"WERTYUGJIYYY!"
INT 21H
RET
CMMP ENDP
CODE ENDS
END START