This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MS/CW-style inline assembly for GCC


Stan Shebs <shebs@apple.com> writes:

> It's almost comical to have people working so hard to rationalize the
> GCC syntax; if you sat a bunch of users down with the different
> syntaxes, and said "which do you prefer?" do you really think they
> would choose the GCC syntax over the CW syntax?

I would.  The gcc syntax lets me say what I want in a clear and
unambiguous manner.  For me the gcc asm syntax, when I first started
using it back in 1990 on the 68k, was a breath of fresh air.  There is
no guesswork about what is going to happen.  You say what you want,
and the compiler handles the details you don't want to worry about.

I haven't used the CW syntax.  But even on a fairly regular
architecture like the PowerPC, it seems fraught with potential for
confusion.  What happens with
    asm { addi a, b, c }
?  When writing in gcc syntax, you can specify that "c" must be an
integer, and get an appropriate error if it is not.  While I'm sure
that you also get an error in CW syntax, what error do you get?

> Memory clobbering
> issues are the same as for asm statements today, 

Why is it the same?  In gcc syntax I can specify whether memory is
clobbered.  In CW syntax I can not.  How do I use CW syntax to make a
supervisor call into my RTOS?  How do I tell gcc what has been changed
if I do that?  In particular, how do I tell gcc that memory is not
clobbered but that specific registers are clobbered?

> and registers it
> knows about because it parses all the operands.

Isn't this going to be rather problematic on a less regular
architecture, like the 68k, or the x86?  On the x86, it seems like the
compiler will have to understand all the weird and wonderful
instructions like "rep movs".  That's a lot of parsing.

> Implicitly clobbered
> registers would be more work, but worth it - that is another
> limitation of the GCC asm statement that drives users crazy.

What is the limitation?  The gcc syntax lets you specify precisely
which registers are clobbered.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]