Re: a modest proposal



Craig Powers wrote:
.... Inline asm is where
you have a snippet of code written asm embedded in the body of code written in some other language. I'd expect it to only be applicable in two cases: first, writing low-level code (like a device driver), and second, where something can be hand-optimized in asm better than the compiler's own optimizer.

Count me as dubious.

With a general asm facility, the compiler has to first save all the
registers and whatnot into some known state. And afterwards, it has
to reload them all. Just like an ordinary procedure call. So it seems
like for short snippets of asm code, you pay a larger price than it may
be worth. For longer code sequences, why bother with inline code?
Just make them self-contained asm procedures.

If there are a few useful machine instructions that the compiler is
incapable of generating, then a set of cpu-specific intrinsic functions
seems like the Right Way to go. The compiler can 'inline' the desired
instruction and optimize its integration into the surrounding code. Many
compilers have used this technique over the past few decades with good
results.

W.
.