views:

91

answers:

2
+2  Q: 

AT&T inline syntax

can anyone show my the correct AT&T syntax to do what i'm doing below in INTEL i've shown my attempts at AT&T, but they don't compile...

unsigned int CheckIfGenuineIntel(void)
{
    unsigned int VendorIdentificationString[4] = {0, 0, 0, 0};

#if defined( _DO_INTEL_ )
    __asm__ __volatile__
    (
        "xor eax, eax\n\t"
        "cpuid\n\t"
        "mov %0, ebx\n\t"
        "mov %0 + 4, edx\n\t"
        "mov %0 + 8, ecx"
        :"=m"(VendorIdentificationString)
        :
        :"eax", "ebx", "ecx", "edx"
    );
#else
    asm volatile
    (
        "xor %%eax, %%eax\n\t"
        "cpuid\n\t"
        "movl %%ebx, %0\n\t"
        "movl %%edx, 4(%0)\n\t"
        "movl %%ecx, $8(%0)"
        :"=m"(VendorIdentificationString)
        :
        :"eax", "ebx", "ecx", "edx"
    );
#endif

    printf("\nCheckIfGenuineIntel:  '%s'\n", (char *)&VendorIdentificationString[0]);
    return 1;
}
+1  A: 

These lines:

"movl %%edx, 4(%0)\n\t"
"movl %%ecx, $8(%0)"

should be:

"movl %%edx, 4+%0\n\t"
"movl %%ecx, 8+%0"

That seems to make gcc 3.4.4 happy.

Aaron
A: 

Have a look at intel2gas, which is a tool to translate from Intel syntax to AT&T syntax.

P-Nuts