Removing it from the routine and setting it just before enter() is called should fix that, or no?
New code:
unsigned short kp, pwd[4], l01, l02, l03, l04, l05, l06, pchk;
int i;
char keypadPort at PORTD;
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at...