piclist 2005\08\02\005952a >
Thread: INC/DEC 2 PACKED BCD NUMBERS
www.piclist.com/techref/microchip/devices.htm?key=pic
face
flavicon
face BY : Andrew Warren email (remove spam text)



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 - spamBeGonefastfwdspamTakeThisOuTix.netcom.com

<42EE9BFD.4991.5FB57@fastfwd.ix.netcom.com> 7BIT

In reply to: <000a01c596c3$83fad490$0d00040a@braile.intranet>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) INC/DEC 2 PACKED BCD NUMBERS

month overview.

new search...