RE: 16-bit arithmetic in C

Andy Kunz proposed:

David E. Olson replied:

Andy Kunz came back with:

It certainly would make a neat macro if it worked.  However, I've just tried it on V7.85, compiling for a 16F877 with maximum optimisation and it got it's knickers in a twist:

This is moving the CCPR1H and CCPR1L registers in a global unsigned int called "count"

        movf    21,w    ;volatile
        movwf   btemp+1
        clrf    btemp
        movf    22,w    ;volatile
        iorwf   btemp,w
        movwf   _count
        movf    btemp+1,w
        movwf   _count+1
   
As all registers are in bank 0, this should boil down to 4 instructions, with no temps being needed.  Any comments Clive if you're listening?

Regards

Mike Rigby-Jones