;File incdec.asm - Blinks LEDs on PORTB outputs in a sequential pattern. ;Configuration - RC oscillator, watchdog timer off, power-up timer enabled. processor 16f84A include __config _RC_OSC &_WDT_OFF &_PWRTE_ON ;Declare variables at two memory locations J equ H'1F' ;J stored at hex address 1F. K equ H'1E' ;K stored at hex address 1E. ;Program org 0 ;Start program at address zero. ;Set PORTB as output and initialize it. movlw B'00000000' ;Move 8 binary zeros to the W (working) register tris PORTB ;Sets all of the pins of PORTB as outputs movlw B'00011' tris PORTA ;Sets all of the pins of PORTA movlw B'00000000' movwf PORTB ;Turns off all of the outputs of PORTB ;Scan input switches. SCAN btfsc PORTA,0 ;Skip INCREMENT if PORTA pin 0 is low call INCREMENT ;btfsc PORTA,0 ;Skip WAIT if PORTA pin 0 is low ;call WAIT btfsc PORTA,1 ;Skip DECREMENT if PORTA pin 1 is low call DECREMENT ;btfsc PORTA,1 ;Skip WAIT if PORTA pin 1 is low ;call WAIT goto SCAN ;Check switches again. ;Increment output INCREMENT incf PORTB btfss PORTB,3 ;Skip return if PORTB pin 3 is high return btfss PORTB,1 ;Skip return if PORTB pin 1 is high return movlw B'00000000' ;The number 10 was found so reset to 0 movwf PORTB ;clear PORTB return ;Decrement output DECREMENT decf PORTB btfss PORTB,3 ;Skip return if PORTB pin 3 is high return btfss PORTB,2 ;Skip return if PORTB pin 2 is high return btfss PORTB,1 ;Skip return if PORTB pin 1 is high return btfss PORTB,0 ;Skip return if PORTB pin 0 is high return movlw B'00001001' ;The number 0 was found so reset to 9 movwf PORTB ; return ;Wait until the button is released (we want to count button presses) WAIT LOOK btfsc PORTA,0 ;Skip if PORTA pin 0 is low goto LOOK btfsc PORTA,1 ;Skip if PORTA pin 1 is low goto LOOK return end