Reputation: 131
For inline asm code I use __asm
for vc++ compiler and __asm__()
or asm()
construct for gcc under linux. (intel/at&t syntax accordingly)
Is there a way to declare inline assembly (x86) in C for them both in a universal way?
P.S. An automated tool for incorporating both is also acceptable.
Upvotes: 0
Views: 311
Reputation: 11929
As an alternative...
I presume you use Visual C because it's a Windows platform?
Why not use gcc for both Windows and Linux platforms?
Then it's the same source and same assembly format !
Upvotes: 0
Reputation: 11929
Put the assembly in a macro and use the pre-processor to make the correct code.
#ifdef GCC
#define MY_ASM_CODE __asm() { blah blah blah}
#endif
#ifdef MSVC
#define MY_ASM_CODE __asm { blah blah blah }
#endif
int main(void)
{
MY_ASM_CODE;
return 0;
}
Upvotes: 5