Yes, this is the C that I believe generated the good code. I can't test now myself either :-( Boating season is here! Andy "David E. Olson" on 03/21/2000 06:11:49 PM Please respond to pic microcontroller discussion list To: PICLIST@MITVMA.MIT.EDU cc: (bcc: Andrew Kunz/TDI_NOTES) Subject: Re: 16-bit arithmetic in C First of all, many thanks on the input. [Various bits from Michael and Andy snipped...] > union intchar /* define the union variable type */ I thought about a union too. It, for some late night reason, seemed clunky. But now that I see it after some rest, it doesn't look too bad. I may try a few options and see what I get out when it compiles. > I try and use these constructs to stay away from inline asm wherever possible, but sometimes it really is > needed. You can use this method to access bits in a char or int as well. Have a look on HiTechs FAQ page at > http://www.htsoft.com/ for more details. Forgot to go to the FAQ - perused the PIC archives and Hi-Tech's on-line discussions. > 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); > 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. -DO