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

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

[avr-gcc-list] multiplication order effects machine cycles?


From: intiha Ho gai
Subject: [avr-gcc-list] multiplication order effects machine cycles?
Date: Thu, 13 Oct 2005 10:22:04 -0700

Hello everyone,
In one of the programs that I am trying to optimize there is a long multiplication (I am using Atmega128L). Using GPIO toggling across the lines of code I get the following result


double skew_;
int32_t offset_;//can also be negative
uint32_t full;

//assume full to be initialize dto something
GPIO(on)//my own MACRO
full  = (uint32_t)(skew_*(double)full + offset_); //this gives me 348usec on the scope
GPIO(off)

REPLACEMENT CODE FOR ABOVE LINE
GPIO(on)
   full+=offset_;
   full  =(uint32_t) skew_ *(double)full; //AFFAN: by observing the scope results, for some reason this results in less time spent (180 us as opposed to 348 usec above)
GPIO(off)

Can anyone explain why this significantly large change has happened. I know I cna lok at the disassembly, but is there any intuitive reason/principal that I can lear from this about how to code multiplication.

Thank you

Affan



reply via email to

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