汇编语言程序设计,比较两个字符串是否相同

编写一段程序,比较两个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

 

    原文作者:Wuliwuliii
    原文地址: https://blog.csdn.net/qq_41730082/article/details/102790921
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞