movlw 0x01
movwf mode ;This tells if your counting up or down, or not at all
;2 = counting up
;1 = not counting
;0 = counting down
main_loop
btfsc PORTA,0 ;this is the count up button
goto set_mode_up
btfsc PORTA,1 ;this is the count down button
goto set_mode_down
btfsc PORTA,2 ;this is the stop button
goto set_mode_stop
[COLOR="Red"]; this will fall through and cause the code to count up.[/COLOR]
set_mode_up
movlw 0x02
movwf mode
goto count
set_mode_stop
movlw 0x01
movwf mode
goto count
set_mode_down
movlw 0x00
movwf mode
goto count
count
;see if mode was 0
movfw mode
btfss STATUS,Z
goto count_down
;see if mode was 1
xorlw 0x01
btfss STATUS,Z
goto count_stop
xorlw 0x01
;see if mode was 2
xorlw 0x02
btfss STATUS,Z
goto count_stop
;if all else fails, stop the count by default
goto count_stop
count_up
incf PORTB
call delay
goto main_loop
count_down
decf PORTB
call delay
goto main_loop
count_stop
call delay
goto main_loop