编写一段程序,比较两个5字节的字符串OLDS和NEWS,若相同,将RESULT置0,否则置0FFH。
那么,我们可以假设他们一开始是相同的,遇到不同的时候直接返回给置数0FFH即可。
STACK SEGMENT PARA 'STACK'
DB 100 DUP(?)
STACK ENDS
ASSUME DS: SEG1, CS: SEG2
SEG1 SEGMENT
OLDS DB 'ABCDE'
NEWS DB 'AACDE'
RESULT DB 0
SEG1 ENDS
SEG2 SEGMENT
START:
MOV AX, SEG1
MOV DS, AX
MOV ES, AX
MOV DI, OFFSET OLDS
MOV SI, OFFSET NEWS
MOV CX, 5
LOP:
MOV AL, [DI]
MOV AH, [SI]
INC DI
INC SI
CMP AL, AH
JNZ DIFF
DEC CX
JNZ LOP
JMP LAST
DIFF: MOV [RESULT], 0FFH
LAST:
SEG2 ENDS
END START