[Top][All Lists]

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

Re: [avr-gcc-list] Is it possible to implement...

From: John . Johnson
Subject: Re: [avr-gcc-list] Is it possible to implement...
Date: Fri, 3 Jan 2003 15:10:14 -0500

> On 30 Dec 2002 at 21:59, Rune Christensen wrote:
> Is it possible to implement the following code in avr-gcc not using
> assembler
> if (carry(csumlo += data))
> {
>   if (carry(++csumhi))
>   {
>     csumlo++;
>   }
> }

I am not (yet) a user of avr-gcc but I would assume the compiler is
internally optimized for 16/8 bit adds and thus would already implement 16
bits adds optimized as you describe.

I suggest that you might be able to use a data structure comprising a union
of a two byte array with a 16 bit "word"; the two byte array would be the
HI and the LO components of your csumlo/hi result. And add to the "word"
component would then be automatically reflected in the HI and LO components
in the two byte array as appropriate.

John Johnson

avr-gcc-list at http://avr1.org

reply via email to

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