on-internet
← Community

Adding with carry on PIC16 (or similar)

Stack Overflow ·

There is no "add with carry" instruction on PIC 16. But what if I had to add larger data quantity than just a byte? All the Web resources and Microchip application notes I've found suggest something like: MOVF LSB_A, w ADDWF LSB_B MOVF MSB_A, w BTFSC STATUS, C INCFSZ MSB_A, w ADDWF MSB_B but the code above will just not work. I mean the 16-bit result will be correct, but the carry won't be set properly, so you can't just expand the computational range by repeating the second part of the code above. Am I right so far? Below is my implementation of addition with carry: MOVF BYTE1, w BTFSC STATUS

Comments

Sign in or sign up to comment and upvote.

No comments yet.