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=1 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 > > === 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 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist