[sdiy] Quick C query
Veronica Merryfield
veronica.merryfield at shaw.ca
Sun Nov 21 22:04:26 CET 2010
On 2010-11-21, at 12:31 PM, Jason Proctor wrote:
>> Which gets me back to knowing what the compiler does with code. Output to a listing file and look can get you a very long way before having to goto assembly.
>
> seconded. i wrote gobs of C before i did any assembler, hence i learned a lot by having the compiler compile, but not assemble or link. studying the assembler output can be very enlightening indeed, especially while varying the optimisation settings.
A few years into my career in embedded software I found that one can not rely on optimisations. The typical pattern is to write code and debug it and switch optimisation to get it to run faster, often leading to code was very hard to debug and could lead to unexpected side effects which were now hard to debug. I learnt to write code that gained little by changing options which meant I had debuggable code with decent performance.
I know some will say that there are somethings that a compiler can optimise that you can't write in the C, but if you find out what it does and learn from it, there is a lot you can do that will get your code very close.
About 14/15 years back I was working on IR video streaming to disk and live on windows 95. My colleague and I had the same ideas on this and we were doing things in windows that our competitors thought we must be cheating on in some way, but it was all written in C with no optimisation - very slick.
More information about the Synth-diy
mailing list