list p=16F877A ; list directive to define processor
#include <p16F877A.inc> ; processor specific variable definitions
__CONFIG 0X3F32
ORG 0x200 ; processor reset vector
goto main ; go to beginning of program
main
BCF STATUS,RP1
BSF STATUS,RP0 ;SWITCH TO BANK 1
CLRF TRISB ;SET PORTB AS OUTPUT
BSF TRISA,2 ;SET RA2 AS INPUT
BSF TRISA,3 ;SET RA3 AS INPUT
BSF TRISA,4 ;SET RA4 AS INPUT
BCF STATUS,RP0 ;BANK 0
CLRF PORTB ;SET ALL 8 PIN IN PORTB TO LOW(0)
;the main program begin here
START
BTFSS PORTA,2 ;check signal at pushbutton1, if press then goto following line, else skip the following line
CALL RED ;button1 pressed, program execute the operation in subroutine RED
BTFSS PORTA,3 ;check signal at pushbutton2, if press then goto following line, else skip the following line
CALL GREEN ;button2 pressed, program execute the operation in subroutine GREEN
BTFSS PORTA,4 ;check signal at pushbutton3, if press then goto following line, else skip the following line
CALL YELLOW ;button3 pressed, program execute the operation in subroutine YELLOW
GOTO START ;no any button being pressed, program keep looping to check the pushbuttons' signal
RED
BSF PORTB,4 ;ON YELLOW LED
BSF PORTB,5 ;ON GREEN LED
BCF PORTB,6 ;OFF RED LED
RETURN
GREEN
BSF PORTB,4 ;ON YELLOW LED
BCF PORTB,5 ;OFF GREEN LED
BSF PORTB,6 ;ON RED LED
RETURN
YELLOW
BCF PORTB,4 ;OFF YELLOW LED
BSF PORTB,5 ;ON GREEN LED
BSF PORTB,6 ;ON RED LED
RETURN
END ; directive 'end of program'
can somebody help me to check it ma ?? as after i burn i the hardware i can gtt what i want. actually the output i want is very simple. like i press the pushbutton port A2, the subroutine red will operate and after i press other button i will go to other subroutine. hope somebody will reply me. thank a lot.