RE: 16-bit arithmetic in C

Ok, been doing a bit of fiddling.

I found an include that I downloaded while back, but never really looked at.  Amongst other stuff, the file defines the following:

#define byte0(x)                (unsigned char)(*(((unsigned char *)&x)+0))
#define byte1(x)                (unsigned char)(*(((unsigned char *)&x)+1))

To use this you would do the following (assuming count is your 16bit var):

        byte0(count) = CCPR1L;
        byte1(count) = CCPR1H;

This compiles to the expected 4 instructions.  The file, along with some other good stuff for HiTech C can be found at http://www.keyghost.com/

Regards

Mike Rigby-Jones