2016-11-22 83 views
0

根據intel參考手冊,如果CPUID.(EAX=14H, ECX=0):EBX.PTWRITE [Bit 4] = 0如何檢查CPUID。(EAX = 14H,ECX = 0)?

指令會拋出#UD異常如何檢查這些值?

如果我使用int __get_cpuid (unsigned int __level, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx)<cpuid.h>那麼應該是什麼參數?

回答

2

你不能使用它。你需要一個版本,你也可以通過ecx,因爲它必須是零。如果可用,您可以使用__cpuid_count,例如:

unsigned eax, ebx, ecx, edx; 
if (__get_cpuid(0x00, &eax, &ebx, &ecx, &edx) == 0) { 
    // cpuid not supported 
} 
if (eax < 0x14) { 
    // leaf 0x14 not supported 
} 
__cpuid_count(0x14, 0x00, eax, ebx, ecx, edx); 
if ((ebx & 0x10) == 0) { 
    // PTWRITE not supported 
} 
+0

請修復它。它應該是:((ebx&0x10)== 0) 我花了幾天的時間搞清楚爲什麼我的代碼給了我一個非法的指令異常,即使它被支持。最後用不同的編譯器編譯你的代碼,它給了我一個關於運算符優先級的警告。大聲笑 – pizzaEatingGuy

+0

哎呀,對不起。 – Jester

相關問題