[sdiy] Quick C query
Olivier Gillet
ol.gillet at gmail.com
Sun Nov 21 21:40:50 CET 2010
> You'd be surprised how much you can hand assemble in C if you understand what the compiler is doing. Most embedded application projects do not change the tools during the life of the project so tuning the C to the output is not the heinous sin it would first appear.
Oh, I was going to write exactly that! What I was going to suggest Tom
was to take some time with a disassembler to study carefully the
generated code for all the C constructs, multiplications / shifts
between various datatypes, function calls, ISR preludes/postludes + to
check if there's some overhead with inlined assembly ; and to get a
rough idea of the effects of compiler optimization flags, etc. Then
make some educated choices with the constructs used in his code. This
breaks the "portability/machine independence" purpose of C since it
bends the code towards a target of choice (but then it doesn't make it
totally unportable). This absolutely won't break the readability and
"wide angle" view on the code C offers - and those last two are
absolutely valid reasons for using a high-level language.
What I learned by doing this on avr-gcc is that there are few blind
spots - and those are not due to compiler weakness but to the fact
that it's hard to express in C things about data sizes - "this 16x16
multiplication is indeed 8.4 x 8.4 and I will only care about the 16
highest bits of the result" etc.
More information about the Synth-diy
mailing list