title: Adding with carry on PIC16 (or similar)
body: <p>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:</p>
  
  <pre><code>MOVF   LSB_A, w
  ADDWF  LSB_B
  
  MOVF   MSB_A, w
  BTFSC  STATUS, C
  INCFSZ MSB_A, w
  ADDWF  MSB_B
  </code></pre>
  
  <p>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?</p>
  
  <p>Below is my implementation of addition with carry:</p>
  
  <pre><code>MOVF    BYTE1, w
  BTFSC   STATUS, C
  ADDLW   1
  RLF     TEMP       ; save the carry
  ADDWF   BYTE2
  BTFSS   STATUS, C
  RRF     TEMP       ; restore the carry (from the first addition)
  </code></pre>
  
  <p>You can use plain addition for the least significant byte or clear the carry before using a sequence of additions with carry.
  I guess it works, but are there more effective solutions to this problem?</p>