Got any evidence of the opposite? No? Didn't think so.Rusky wrote:Got any evidence of that? No? Didn't think so.Casm wrote:I would second that; especially if there is a loop with a large number of iterations involved. In assembly language there can be a noticable blip whilst the loop is executing, but the same thing coded in C can leave you thinking that the computer has hung.Love4Boobies wrote: Nah, even today. We just tell people they're good at it to trick them into avoiding a premature optimization. For the moment, they're very far from beating an experienced assembly programmer.
If you're writing a large application, the normal "rule of thumb" is that 90% of CPU time will be spent in 10% of the code. For the other 90% of the code a good/experienced programming will care more about code maintenance than optimising, but a compiler won't care and will optimise it anyway; and as a result for about 90% of the code the compiler will beat a good/experienced assembly programmer.
For the remaining 10% of the code (where the CPU spends about 90% of the time); most people would start by disassembling the compiler's output and then tweaking it. Done like this, for parts that are worth optimising, assembly should never be worse than C. It's also not too hard for a good/experienced assembly programmer to get (sometimes significant) performance improvements.
Now, for an entire OS written in assembly, the same thing applies - you can expect about 90% of the code to be worse than compiler generated code and 10% to be the same or better; and you can expect the CPU to spend about 90% of it's time in better assembly code and 10% of it's time in worse assembly code.
This "90% and 10%" thing doesn't apply for some parts though. For something like a micro-kernel it's a lot closer to "50% and 50%"; and for some things (e.g. "PC BIOS" boot code) you're mostly screwed if you try to use a compiler.
None of the above mentions the effect on development time either. As a rough estimate, it will take about twice as long to do anything in assembly, regardless of what it is.
If you weigh up the advantages (faster were it matters) and disadvantages (slower were it doesn't matter, longer development time, no portability); the most obvious choice is to do everything you can in something like C and then worry about optimising small parts in assembly later (after you've done profiling, etc).
Of course in some cases there may be other reasons to use assembly beyond performance alone (for example, maybe you just like assembly more).
Cheers,
Brendan