#include <p16f877A.inc>
ORG 0020
bsf STATUS, RP0 ;set RP0
bcf STATUS, RP1 ;clear RP1
movlw 0xff ;set PORTA as input
movwf PORTA
movlw 0x00 ;set PORTB as output
movwf TRISB
BCF TRISB,2
BCF TRISB,3
BSF TRISA,0
BSF TRISA,2
BSF TRISA,3
H: BTFSS PORTA,0
GOTO H
H2: BTFSS PORTA,2
BTFSS PORTA,3
GOTO RLY1
GOTO H
RLY1: BSF TRISB,2
BSF TRISB,3
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
S1: BTFSC PORTA,2
S2: BTFSC PORTA,3
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
GOTO S1
GOTO s2
GOTO H
END