C++ inline asm AT&T sucks!!!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
krillzip

C++ inline asm AT&T sucks!!!

Post by krillzip »

Now I am trying to fix width inline asm to my C++ OS, I'm using DJGPP and I don't like the AT&T synatx.
Is there a work-around or something so I can use Intel syntax??
Chase

RE:C++ inline asm AT&T sucks!!!

Post by Chase »

You could either use external assembly (link w/NASM code)
or
Write in intel and convert it to at&t syntax using Intel2gas
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas/

I don't know of any way to directly use Intel syntax with gcc.
J.

RE:C++ inline asm AT&T sucks!!!

Post by J. »

I think it's actually possible!  I swear I remember reading something about
the newest version of either DJGPP or GCC now having support for Intel syntax
assembly.

Unfortunately, that's all the help I can be... I don't know _how_ to do it,
but I think it's possible.  Possibly a question for DJ Delorie and the DJGPP
crew?

If I find out, I'll give a posting...

Oh here it is... searching on google yielded this:
http://www.delorie.com/djgpp/v2faq/faq17_1.html

The last couple paragraphs are of interest to you... it's possible.  There's
a web site to tell you how to do it (unfortunatley, the link doesn't work),
but I'm sure with some more searching you can find out how (if not, let me
know and I'll see what I can find out).

PS: According to that same page, Binutils 2.1+ will _most likely_ support
Intel as well as AT&T syntax (which version of the binutils does djgpp
currently use?)

Jeff
Chase

RE:C++ inline asm AT&T sucks!!!

Post by Chase »

Accourding to the gas documentation at
http://sources.redhat.com/cgi-bin/cvswe ... vsroot=src

Changes in 2.10:
A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386
assembly programs with intel syntax.

The gas that comes with djgpp is at version 2.11.2 So I guess intel syntax feed into gas will work but I have to wonder if gcc would complain about the intel syntax before it made it's why to gas....

Any one got some spare time to try it out?-) (using gas for normal intel syntax and inline intel syntax)
J.

RE:C++ inline asm AT&T sucks!!!

Post by J. »

Yeah, it'll work.  GCC doesn't check validity of inline asm (or do anything
with it, for that matter)... that's why I hate inline asm... you get error
messages like this:

/tmp/ccY0DAMR.s: Assembler messages:
/tmp/ccY0DAMR.s:25: Error: no instruction mnemonic suffix given and no register operands; can't size instruction

Which is all fine and dandy, expect that the C program that all that came
from is all of 10 lines... and yet there's an error on line 25!?  (because
it's basing it's line numbers of the asm generated from the C source... it
has no idea the asm is even from a C file).

Just to be sure, I tried the following (useless) program:


int main(void) {
  __asm__("
    .intel_syntax \n
    movw eax, 0xffff");

  return 0;
}

And it works (note the opcodes are still AT&T style... movw, not just mov, but
the order is Intel).

Jeff
Post Reply