Decrementing packed BCD

Discussion in 'Embedded Systems and Microcontrollers' started by RG23, May 10, 2011.

  1. RG23

    Thread Starter Active Member

    Dec 6, 2010
    301
    2
    incf count304,1 ////count304 is h'00'
    movf count304,0
    addlw 0x06
    btfss STATUS,DC
    addlw -0x06
    addlw 0x60
    btfss STATUS,C
    addlw -0x60
    movwf count304

    The above subroutine enables me to increment from 00 to 99 on LCD display

    It didn't work while decrementing from 99 to 00

    If anyone has an idea please let me know

    Thanks
     
    Last edited: May 10, 2011
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    This will do it:
    movlw 0x01
    subwf count304, W
    btfss STATUS, DC ;if digit borrow then subtract another 6 eg 0x8F
    addlw -0x06 ;would become 0x89
    movwf count304
     
Loading...