Andy Kunz proposed:
> At one time I believe I checked and found the HTC generated comparable
code to
> what I proposed in assembly.
>
> I think it does this correctly:
>
> int counter;
> counter = (CCPR1H << 8) | (CCPR1L);
>
David E. Olson replied:
This is what I thought could be done. While the union gives me access to all
the entities, I'll have to further look to see I need the hi and low order
bytes when I'm done. Chances are, no.
Question for Andy - is the above example what you found to be comparable to
the assembly routine you posted? Unfortunately I'm not at my dev machine
right now to try it out.
Andy Kunz came back with:
Yes, this is the C that I believe generated the good code. I can't test now
myself either :-(
Boating season is here!
Andy
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