list P = 16F877
#INCLUDE <p16f877.inc>
; -------------------------------------------------------------
#Define Switch1 PORTB,4
#Define Switch2 PORTB,5
#Define Switch3 PORTB,6
#Define Switch4 PORTB,7
#Define Output1 PORTB,0
#Define Output2 PORTB,1
#Define Output3 PORTB,2
#Define Output4 PORTB,3
org 0x0000
;##########################################################################
Start
bsf STATUS,5
movlw b'11110000' ;4 inputs 4 outputs
movwf TRISB ;RB outputs
bcf STATUS,5
clrf PORTB
MainLoop
btfsc Switch1
goto Switch_1_Is_0
bcf Output1 ;set "0" RB0
goto Check_Switch_2
Switch_1_Is_0
bsf Output1 ;set "1" RB0
Check_Switch_2
btfsc Switch2
goto Switch_2_Is_0
bcf Output2
goto Check_Switch_3
Switch_2_Is_0
bsf Output2
Check_Switch_3
btfsc Switch3
goto Switch_3_Is_0
bcf Output3
goto Check_Switch_4
Switch_3_Is_0
bsf Output3
Check_Switch_4
btfsc Switch4
goto Switch_4_Is_0
bcf Output4
goto MainLoop
Switch_4_Is_0
bsf Output4
goto MainLoop
end ; end of program