2009-12-18 96 views
2

任何人都可以證明我的正確的AT & T語法做下面我做在INTEL 什麼我在AT &牛逼顯示我的嘗試,但他們並不編譯...AT&T在線語法

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; 
} 
+2

您能否修復格式? – ndim

回答

1

這些行:

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

應該是:

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

這似乎讓gcc 3.4.4開心。

0

看看intel2gas,這是一個將英特爾語法翻譯爲AT語法的工具。