Thank you very much to all that helped me, especially to Andrew and Dmitriy. I=B4m going to do some tests to INC/DEC the high byte using the last example of Dmitriy. Luis F. ----- Original Message -----=20 From: "Dmitriy Kiryashov" To: "Microcontroller discussion list - Public." Sent: Monday, August 01, 2005 6:48 PM Subject: Re: [PIC]: INC/DEC 2 PACKED BCD NUMBERS > Hi Andy. > > Squeezing the lemon :) > > incf reg,F ;INCF REG > movlw 0x66 ;MOVLW 0x06 > addwf reg,F ;ADDWF REG > skpndc ;SKPDC > andlw 0xF0 ;SUBWF REG > skpnc ;MOVLW 0x60 > andlw 0x0F ;ADDWF REG > subwf reg,F ;SKPC > ;SUBWF REG ;;btw here Cy is always=3D1 > > > movlw 0x01 ;MOVLW 1 > subwf reg,W ;SUBWF REG > skpdc ;MOVLW 0x06 > xorlw 0x06 ;SKPDC > skpc ;XORWF REG > xorlw 0x60 ;MOVLW 0x60 > movwf reg ;SKPC > ;XORWF REG > > > I think it is in piclist archive somewhere. > > > WBR Dmitry. > > > > Andrew Warren wrote: >> >> Luis: >> >> This comes up every once in a while and is likely to be in the >> archives somewhere. >> >> The last time I answered the question, I came up with these. I >> didn't assemble or test them, but no one complained that they failed >> to work... >> >> To increment one byte: >> >> INCF REG >> >> MOVLW 0x06 >> ADDWF REG >> SKPDC >> SUBWF REG >> >> MOVLW 0x60 >> ADDWF REG >> SKPC >> SUBWF REG >> >> To decrement one byte: >> >> MOVLW 1 >> SUBWF REG >> >> MOVLW 0x06 >> SKPDC >> XORWF REG >> >> MOVLW 0x60 >> SKPC >> XORWF REG >> >> The Carry flag is valid after each of those, so first inc/dec the low >> byte, then use the carry to decide whether to inc/dec the high byte. >> >> -Andy >> >> =3D=3D=3D Andrew Warren - fastfwd@ix.netcom.com >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist=20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist