FINDN:
MOV A,R0
MOV R2,A
MOV A,ADDPL
MOV DPL,A
MOV A,ADDPH
MOV DPH,A
MOV A,R7
JZ FINDN1
INC R6
FINDN1:
MOV A,R2
MOV R0,A
MOV A,N
MOV NCNT,A
FINDN2:
MOVX A,@DPTR
CLR C
SUBB A,@R0
JNZ FINDN3
INC DPTR
INC R0
DJNZ NCNT,FINDN2
MOV A,DPL
CLR C
SUBB A,N
MOV ADDPL,A
MOV A,DPH
SUBB A,#00H
MOV ADDPH,A
CLR A
RET
FINDN3:
CLR C
MOV A,R0
SUBB A,R2
JNZ FINDN4
INC DPTR
FINDN4:
DJNZ R7,FINDN1
DJNZ R6,FINDN1
MOV A,#0FFH
RET