On Fri, 27 Oct 2000 21:45:11 -0700, you wrote: >Hi Everyone. > >I've encountered an interesting problem porting a small application >from a 16C77 to an 18C452. I'm using HI-TECH PIC C on the '77 and >HI-TECH PIC18 C on the '452. > >The problem involves reading the 16-bit register Timer1. On the '77, >TMR1H and TMR1L are both readable, and so I declare: > > static volatile unsigned INT TMR1 @ 0x0E; > >and do something like > > counter =3D -TMR1; > >and that works fine. The trouble is that on the '452, TMR1H is only >updated (it's really just a holding register) when TMR1L is read, and >unluckily for me > > counter =3D -TMR1; > >compiles/assembles to code that reads the high byte first, then the >low byte, and so the result in is worthless. > >What is an elegant way to stay as much as possible in 16-bit land yet >"persuade" the compiler to read the low byte first? I wouldn't bother. If you need a specific order it is far better to do it explicitly, otherwise you may get bitten if the compiler changes.=20 counter =3D TMR1L=20 counter |=3D TMR1H<<8 should be no less code-efficient and it is more 'obvious' what is required. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu