Compare two strings in extended memory - classic 8052
AT89S52 is not a classic 8052. Like all modern 8052 variants I know of, it has one feature which really shines here. Namely, it is dual data pointers. Instead of reloading DPL and DPH every time, initialize them once, and just toggle the AUXR1.DPS bit:

; setup
    clr AUXR1.DPS
    mov DPL, R2
    mov DPL, R3

    cpl AUXR1.DPS
    mov DPL, R4
    mov DPL, R5
    ....

; loop
checknexbyte:
    cpl AUXR1.DPS
    movx A, @DPTR
    mov B, A
    inc DPTR

    cpl AUXR1.DPS
    movx A, @DPTR
    inc DPTR

    cjne mismatch
    djnz R7, checknextbyte
mismatch:

You may spare a register (R6), few cycles, and some bytes by using C flag (set by CJNE) as a match/mismatch indication.
It looks like the exit logic is incorrect. On a mismatch (A != B) the jump is taken, and the loop continues. Correct me if I am wrong.