Check_Keys
movlw b'00000001'
movwf PORTC
movf PORTC, W
andlw 0xF0
btfss STATUS, Z ;test if any key pressed
goto Col1
movlw b'00000010'
movwf PORTC
movf PORTC, W
andlw 0xF0
btfss STATUS, Z ;test if any key pressed
goto Col2
movlw b'00000100'
movwf PORTC
movf PORTC, W
andlw 0xF0
btfss STATUS, Z ;test if any key pressed
goto Col3
movlw b'00001000'
movwf PORTC
movf PORTC, W
andlw 0xF0
btfss STATUS, Z ;test if any key pressed
goto Col4
Col1
movwf key
clrw
goto Check_Row
Col2
movwf key
movlw 0x04
goto Check_Row
Col3
movwf key
movlw 0x08
goto Check_Row
Col4
movwf key
movlw 0x0c
goto Check_Row
Check_Row
movwf index
btfsc key,4
goto Row1
btfsc key,5
goto Row2
btfsc key,6
goto Row3
btfsc key,7
goto Row4
Row1
goto Keys
Row2
incf index
goto Keys
Row3
incf index
incf index
goto Keys
Row4
incf index
incf index
incf index
goto Keys
Keys
movlw HIGH Key_Table
movwf PCLATH
movlw index
call Key_Table
Key_Table ADDWF PCL , f
RETLW 0x31 ;1
RETLW 0x34 ;4
RETLW 0x37 ;7
RETLW 0x2a ;*
RETLW 0x32 ;2
RETLW 0x35 ;5
RETLW 0x38 ;8
RETLW 0x30 ;0
RETLW 0x33 ;3
RETLW 0x36 ;6
RETLW 0x39 ;9
RETLW 0x23 ;#
RETLW 0x41 ;A
RETLW 0x42 ;B
RETLW 0x43 ;C
RETLW 0x44 ;D