184
PROGRAMMING EXAMPLESIII
; Subroutine to match an external array with an internal one.
; If both are matching then, at return, CY f lag is cleared otherwise it is set.
COMPEX: MOV DPTR, #2000H ; initialize external array pointer
MOV R0, #30H ; initialize internal array pointer
MOV R7, #0AH ; initialize counter for 10 bytes
LOOP: MOVX A, @DPTR ; get one external term
CLR C ; compare with corresponding
SUBB A, @R0 ; internal term
JZ NEXT1 ; equal, then jump at NEXT1
SETB C ; unequal, no match, set CY
RET ; and go back
NEXT1: INC DPTR ; point next external term
INC R0 ; point next internal term
DJNZ R7, LOOP ; any more to compare?
CLR C ; no, all term matched, clear CY
RET