4

I've been looking through questions on here and the internet for a while now and I cannot seem to find out whether or not it is possible to do inline assembly with GCC using something other than GAS. I am trying to find if I can avoid using not only GAS's AT&T syntax (though, I know how to use Intel syntax with GAS) but the extended asm format. While this is not for a project or anything other than my own curiosity, I would really appreciate any help I can get (this is actually my first question here because I could not find an answer about it)! Also, if this makes any difference, I'm currently using DevC++ (for C code, not C++) on Windows.

Thanks, Tom

atomictom
  • 143
  • 1
  • 8

2 Answers2

2

You can link the output from an assembler (a ".o" or ".obj" file) with your C or C++ program. Put your assembler code in a text file. Your IDE or makefile will assemble it just as it would any c source file. The only tricky bit is learning how to interface between the two different systems.

Jay
  • 13,803
  • 4
  • 42
  • 69
  • Yeah, and would it be truly "inline" or just be an external function call to an assembler function? And what do you mean by put it in a text file? That the IDE will assemble it for me? – atomictom Feb 08 '11 at 23:24
  • That's not exactly an answer to *"Using another assembler with GCC"* because it does not work for source files with inline assembly. I think @nelhage's answer is the correct one (if its still the case). – jww Sep 26 '15 at 22:30
1

You cannot use another inline assembly syntax with GCC. inline assembly is implemented by GCC literally including the assembly you write inline with its own (textual) assembly output, which it then sends to gas to be assembled. Since GCC doesn't know how to change the format of its own output to feed to another assembler, you can't change the inline assembly, either.

nelhage
  • 2,734
  • 19
  • 14
  • This isn't exactly true; see this SO question: http://stackoverflow.com/questions/199966/how-do-you-use-gcc-to-generate-assembly-code-in-intel-syntax – SpellingD Jun 18 '13 at 20:46