[Top][All Lists]

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

RE: [avr-gcc-list] assembler expressions

From: Ben Mann
Subject: RE: [avr-gcc-list] assembler expressions
Date: Sun, 6 Mar 2005 19:25:10 +0800

Aha. Ok yes I have a look and the preprocessor works _only_ if the value in
the operation doesn't exceed a 32 bit integer *during processing*.

> #define LO_F ( F1 *  F_CPU / (15*16777216) )
> #define HI_F ( F2 *  F_CPU / (15*16777216) )
doesn't work because
F1 * F_CPU is 3e11, and exceeds the 32 bit limit.

The original C compiler example this works because promoting everything to
'float' and then casting back to long works (although in some cases would
reduce accuracy). So I guess the original question comes back - can
typecasts be used on assembler #defines?

Ben Mann

ps - In cases where I've needed 'large' figures before (clock freq etc), an
obvious reduction has presented itself that didn't violate this rule.
Dealing with arbitrary figures like 20000, 15 etc makes it difficult to
understand how this could be optimised.

-----Original Message-----
I know, and you also get the wrong result !
That's why the typecasts are needed. (Or a different way to obtain the 
correct result).
I think it MUST be possible to do this in the assembler (or preprocessor or 
it's SO easy in C.


reply via email to

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