At 01:35 AM 4/10/2006 +0000, jayasooriah wrote:
>--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@...> wrote:
> > I do see uses for assembler, I am just of the opinion, informed
> > by my experiences, that inline assembler causes more problems
> > than it fixes.
>
>My experience tells me otherwise. Inline assembler has its place just
>like any other feature *provided* one understands how to use it before
>one does.
Apparently we have experienced different projects and tools.
I have never used a compiler seriously and not had it break at some point
on me. The only exception so far is GCC. The most common point of
failure, by far, are the architecture specific extensions. Interrupt
keywords, inline assembly, memory placement modifiers etc... Curiously,
the second most common failure point seems to be switch statements.
>If you can give us some examples of where it has caused more problems
>than it fixed, I might be able to explain what I think went wrong.
Problem 1: Nearly all implementations suffer from a lack of
documentation. One case in particular I remember the documentation boiling
down to more or less "the inline asm syntax is asm assembly
instruction;" Needless to say, I didn't even attempt that one.
Problem 2: Incompatible C syntax The form above is obviously not
compatible, so is the form
#asm
assembly instructions
#endasm
They both cause problems with tools and reuse. Tools are generally the
bigger issue.
Problem 3: optimization. If the assembly is just inserted in the middle of
the generated code before being passed to the backend it is sometimes
optimized away.
Problem 4: Register reappropriation. Not a good term but it will do. The
compiler documents the calling convention but when using inline even at the
beginning of the function the compiler appropriates the register for other
temporary uses first so you can never be sure that you will get what you
were expecting when you originally wrote it.
That being said I have run across compilers that only allowed inline (they
had no separate assembler) In both cases though the compilers resembled C
in much the same way Java does so the solution in both cases was really to
get a proper tool chain.
I have used multiple compilers on multiple architectures and experience has
taught me to approach architecture specific extensions with caution and if
their are clear simple alternatives as there are for interrupts and
assembler avoid them all together. I'd rather not spend my time
debugging the compiler if I can avoid it.
Robert
" 'Freedom' has no meaning of itself. There are always restrictions, be
they legal, genetic, or physical. If you don't believe me, try to chew a
radio signal. " -- Kelvin Throop, III
http://www.aeolusdevelopment.com/Message
Re: [lpc2000] Re: Example of C and inline ASM in a file?
2006-04-11 by Robert Adsett
Attachments
- No local attachments were found for this message.