List p=16F877
include "P16F877.inc"
#define in0 PORTB,0
#define in1 PORTB,1
#define in2 PORTB,2
#define in3 PORTB,3
#define in4 PORTB,4
#define in5 PORTB,5
#define in6 PORTB,6
#define in7 PORTB,7
#define ot0 PORTC,0
#define ot1 PORTC,1
#define ot2 PORTC,2
#define ot3 PORTC,3
#define ot4 PORTC,4
#define ot5 PORTC,5
#define ot6 PORTC,6
#define ot7 PORTC,7
org 0x00
goto MAIN
org 0x11
MAIN
call INIT
AGAIN
call CHECK
goto AGAIN
CHECK
btfss in0
goto OFF0
goto ON0
ON0
bsf ot0
goto IN1
OFF0
bcf ot0
IN1
btfss in1
goto OFF1
goto ON1
ON1
bsf ot1
goto IN2
OFF1
bcf ot1
IN2
btfss in2
goto OFF2
goto ON2
ON2
bsf ot2
goto IN3
OFF2
bcf ot2
IN3
btfss in3
goto OFF3
goto ON3
ON3
bsf ot3
goto IN4
OFF3
bcf ot3
IN4
btfss in4
goto OFF4
goto ON4
ON4
bsf ot4
goto IN5
OFF4
bcf ot4
IN5
btfss in5
goto OFF5
goto ON5
ON5
bsf ot5
goto IN6
OFF5
bcf ot5
IN6
btfss in6
goto OFF6
goto ON6
ON6
bsf ot6
goto IN7
OFF6
bcf ot6
IN7
btfss in7
goto OFF7
goto ON7
ON7
bsf ot7
goto Finish
OFF7
bcf ot7
Finish
return
INIT
bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTB
clrf PORTC
bsf STATUS,RP0
movlw B'11111111'
movwf TRISB
movlw B'00000000'
movwf TRISC
bcf STATUS,RP0
return
END