...
PSIFIO2:
DELAY10: MOV R6,#0C3h ; delay for the keys to be pressed
DELAY11: MOV R7,#0FFh
DELAY21: NOP
NOP
DJNZ R7,DELAY21
DJNZ R6,DELAY11


mov R7,#90h
mov A,#0h
call SCAN2 ; scan2 is the routine that scans the keypad
MOV A,R5
CJNE A,#0FFh,ELEGXOSPSIFIOU2 ; check if any key has been pressed and jump to ELEGXOSPSIFIOU2
JMP PSIFIO2 ; ;if no key has been pressed jump to psifio2 and scan again.



ELEGXOSPSIFIOU2:
INC R7
MOV 96h,R5
MOV @R7,96h ;
MOV A,34h
CJNE A,#04h,GRAPSE2 ; Check if it's the 4th key that has been pressed. Go to Grapse 2
TELOS2: JMP ENTER2 ; OR ENTER2
