c compiler inline Intel notation assembly
c compiler inline Intel notation assembly
What are my options ?
Has to comply with ANSI C and if possible be free and isn't likely to die out in the future.
Thanks alot.
Has to comply with ANSI C and if possible be free and isn't likely to die out in the future.
Thanks alot.
The phrase "c compiler inline Intel notation assembly" is pretty vague , but I'm assuming you mean a C compiler with intel syntax for inline assembly.
gcc supports "-masm=intel", but i'm not sure if that also applies to the actual gnu assembler or if you have to supply your own intel-compatible one. IIRC the microsoft c compiler(s) also use intel as their standard assembly syntax.
And of course, it's always possible to just learn the more 'portable' AT&T syntax
gcc supports "-masm=intel", but i'm not sure if that also applies to the actual gnu assembler or if you have to supply your own intel-compatible one. IIRC the microsoft c compiler(s) also use intel as their standard assembly syntax.
And of course, it's always possible to just learn the more 'portable' AT&T syntax
"Sufficiently advanced stupidity is indistinguishable from malice."
Hi,
The GNU compiler collection (GCC) is the de facto compiler set for any unix system. It uses GAS, the GNU assembler, which uses AT&T syntax natively but can be configured via assembler directives to use Intel syntax.
Several people here do this, and it going something like this:
Hope this helps,
James
The GNU compiler collection (GCC) is the de facto compiler set for any unix system. It uses GAS, the GNU assembler, which uses AT&T syntax natively but can be configured via assembler directives to use Intel syntax.
Several people here do this, and it going something like this:
Code: Select all
#define ASM(x) do {asm volatile(".syntax intel"); asm volatile(x); asm volatile(".syntax att");} while (0)
James
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
The GNU Assembler is capable of Intel syntax.
Silly example - Works on OpenBSD(With gcc -O0..):
This may help you: http://www.mirbsd.org/htman/i386/man7/g ... -howto.htm
It would probably be worth while just to learn AT&T syntax, it's a skill worth having.
Silly example - Works on OpenBSD(With gcc -O0..):
Code: Select all
#include <stdio.h>
int main(void) {
int local_var;
asm(".intel_syntax noprefix");
asm("mov dword ptr [ebp-28], 666");
asm(".att_syntax");
printf("%d", local_var);
return 0;
}
It would probably be worth while just to learn AT&T syntax, it's a skill worth having.
"but the works sound lovely" hahahahGavin wrote:I'll go ahead and use the gcc compiler it would be silly to use something else by the looks of it.
I haven't the fogiest what preamble and epilogue is, but the words sound lovely
But thanks .
if they had ratings on this forum, you my friend would get 6 out of 5!
[/OT]
For a very funny result forget the ".att_syntax". I did it once :).Brynet-Inc wrote:Code: Select all
#include <stdio.h> int main(void) { int local_var; asm(".intel_syntax noprefix"); asm("mov dword ptr [ebp-28], 666"); asm(".att_syntax"); printf("%d", local_var); return 0; }
JAL
Re: c compiler inline Intel notation assembly
You most likely mean that the compiler should comply with ANSI C unless you do inline assembly. Nevertheless I'd like to point out that inline assembly never "complies with ANSI C", as ANSI C does not support that technique - it's a compiler-specific extension.Gavin wrote:Has to comply with ANSI C...
Every good solution is obvious once you've found it.