這是原來的代碼進行編譯:我需要幫助英特爾內聯彙編轉換到AT&T這樣我就可以用gcc
#define CPU_PREFETCH(cache_line) \
{ int* address = (int*) (cache_line); \
_asm mov edx, address \
_asm prefetcht0[edx] \
}
#define CPU_GET_CYCLES(low) \
{ \
_asm rdtsc \
_asm mov dword ptr [low], eax \
}
#define CPU_SYNC \
{ \
_asm mov eax, 0 \
_asm cpuid \
}
#define CPU_CACHE_FLUSH(cache_line) \
{ int* address = (int*) (cache_line); \
_asm mov edx, address \
_asm clflush[edx] \
_asm mfence \
}
感謝小丑,我現在有這樣的:
#define CPU_PREFETCH(cache_line) \
{ \
__asm__ __volatile__ ("prefetcht0 %0" : : "m" (*(int*)cache_line)); \
}
#define CPU_GET_CYCLES(low) \
{ \
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "%edx"); \
}
#define CPU_SYNC \
{ \
__asm__ __volatile__ ("cpuid" : : : "%eax", "%ebx", "%ecx", "%edx"); \
}
#define CPU_CACHE_FLUSH(cache_line) \
{ \
__asm__ ("clflush %0; mfence" : : "m" (*(int*)cache_line)); \
}
顯然,海灣合作委員會不喜歡易變與clflush。 謝謝大家。
我想編譯Slicing-By-8與gcc作爲一個DLL,所以我可以在我的VB6應用程序中使用它。
男人,看起來很漂亮,看起來好像你確切地知道你在做什麼:)無論如何,我現在得到這個錯誤:錯誤:操作數大小不匹配'clflush' – selyb 2010-12-19 17:22:26
我試圖點擊這篇文章是有用的,但我不沒有足夠的聲譽 – selyb 2010-12-19 19:14:16