avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Can this be optimised?


From: Royce & Sharal Pereira
Subject: Re: [avr-gcc-list] Can this be optimised?
Date: Wed, 28 Jul 2004 13:23:49 +0530

Hi,
----- Original Message -----

> On Wed, 28 Jul 2004, Royce & Sharal Pereira wrote:
> > Can this be optimised somehow?
> > The following code:-
> > //------------------------------
> > unsigned int tmp;
> > //......etc
> >  tmp= ADCL |(ADCH<<8);
> > //------------------------------
> > gets compiled(correctly) as:
> >
> >  1376 04d0 84B1        in r24,36-0x20
> >  1377 04d2 282F        mov r18,r24
> >  1378 04d4 3327        clr r19
> >  1379 04d6 85B1        in r24,37-0x20
> >  1380 04d8 9927        clr r25
> >  1381 04da 982F        mov r25,r24
> >  1382 04dc 8827        clr r24
> >  1383 04de 282B        or r18,r24
> >  1384 04e0 392B        or r19,r25
> >  1385 04e2 3093 0000   sts (tmp)+1,r19
> >  1386 04e6 2093 0000   sts tmp,r18
> >
> > Is there a way (without using assembly) to shorten this to:
> >
> >               in     rxx,     36-0x20
> >               sts   tmp,    rxx
> >               in     ryy,     37-0x20
> >               sts   tmp+1, ryy
> >
> > Or is in-line assembly the best way?
>
> Sure. Do it like this:
>
>   int main (void)
>   {
>      volatile uint16_t foo;
>
>      foo = ADC;
>
>      return (int)foo;
>   }
-------------------------------------------------------------------
Oh! That simple! I had no Idea sfrs were defined as 16 bit also...In future 
I'll look at the ioxx.h
files much closer..
Thanks!

--Royce.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]