MOV  A,P1        ; load current state of bits 0...3
XRL  A,pin_value ; mask bits which will not be changed
ANL  A,#0x0F     ; mask high nibble
XRL  P1,A        ; change not masked bits