; based on DJNZ - it is simplest
SUBROUTINE_DIP:
	MOV	A,P2
	ANL	A,#00001111b
	JNZ	LABEL_1
; if we are here then value 0 has been read
	RET
LABEL_1: DJNZ	ACC,LABEL_2
; if we are here then value 1 has been read
	RET
LABEL_2: DJNZ	ACC,LABEL_3
; if we are here then value 2 has been read
	RET
; LABEL3...LABEL13 are by same way as above
LABEL_14: DJNZ	ACC,LABEL_15
; if we are here then value 14 has been read
	RET
LABEL_15:
; if we are here then value 15 has been read
	RET