; using free bits as output ones
CLR  P2.7
SETB P2.5
; ...
; now we need read external memory
MOV  DPTR,#MEM_ADDR
MOV  A,P2            ; read current state of bits
ANL  A,#11111000b    ; mask address bits
ORL  DPH,A           ; keep output bits at their state
MOVX A,@DPTR