;-------------------------------------------
keyread clrf portb
clrf portd
bsf portb,4
btfsc porta,ret1
goto r1c1
btfsc porte,ret2
goto r1c2
btfsc porte,ret3
goto r1c3
btfsc porte,ret4
goto r1c4
bcf portb,4
bsf portb,5
btfsc porta,ret1
goto r2c1
btfsc porte,ret2
goto r2c2
btfsc porte,ret3
goto r2c3
btfsc porte,ret4
goto r2c4
bcf portb,5
bsf portb,6
btfsc porta,ret1
goto r3c1
btfsc porte,ret2
goto r3c2
btfsc porte,ret3
goto r3c3
btfsc porte,ret4
goto r3c4
bcf portb,6
bsf portb,7
btfsc porta,ret1
goto r4c1
btfsc porte,ret2
goto r4c2
btfsc porte,ret3
goto r4c3
btfsc porte,ret4
goto r4c4
bcf portb,7
retlw 00
r1c1 bcf portb,4
movlw 07h
return
r1c2 bcf portb,4
movlw 08h
return
r1c3 bcf portb,4
movlw 09h
return
r1c4 bcf portb,4
movlw 0Ah
return
r2c1 bcf portb,4
movlw 04h
return
r2c2 bcf portb,4
movlw 05h
return
r2c3 bcf portb,4
movlw 06h
return
r2c4 bcf portb,4
movlw 0Bh
return
r3c1 bcf portb,4
movlw 01h
return
r3c2 bcf portb,4
movlw 02h
return
r3c3 bcf portb,4
movlw 03h
return
r3c4 bcf portb,4
movlw 0Ch
return
r4c1 bcf portb,4
movlw 10h
return
r4c2 bcf portb,4
movlw 0Fh
return
r4c3 bcf portb,4
movlw 0Eh
return
r4c4 bcf portb,4
movlw 0Dh
return