Example 1
BSF STATUS,5 ; switching from bank0 to bank1
MOVLW 0xFF ;uploading all 1s to W (working register)
MOVWF TRISA; uploading value from W to TRISA in order
; to make PORTA as input
CLRF TRISB; uploading all 0s to TRISB in order to make
; PORTB as output
BCF STATUS,5; switching from bank1 to bank0
MAIN; label (can have any name)
BTFSC PORTA,1; checking if button connected to RA1 is pressed
GOTO LEDON; this line in not skipped in case button is pressed
GOTO LEDOF; in case button is not pressed we are coming here
LEDON ; label (can have any name)
MOVLW 0XFF; uploading all 1s to W
MOVWF PORTB; uploading all 1s from W to
; PORTB to turn on all LEDs
GOTO MAIN; jump to MAIN LABEL
LEDON ;label called LEDON
MOVLW B’11110000';uploading 11110000 or 0xF0 to working reg
MOVWF PORTB ;sending value from working reg to PORTB to turn on specific LEDs
GOTO MAIN ;jump to label called MAIN once LEDON routine is finished
LEDOFF ;label called LEDOFF
CLRF PORTB ;turning off all LEDs of PORTB –clear all bits of PORTB reg
GOTO MAIN ;jump to label called MAIN once LEDOFF routine is finished
END