x86asm汇编读取cpu信息(cpuid指令)
x86asm汇编读取cpu信息(cpuid指令)
#include <stdio.h> int main(void) { unsigned long uId = 0x80000002; char cpu[49]={0}; char* p = cpu; int i; for(i=0; i<3; i++){ __asm{ pushad mov eax,uId cpuid; mov esi,p mov [esi+0],eax mov [esi+4],ebx mov [esi+8],ecx mov [esi+12],edx popad } p += 4*4; uId++; } printf("%s\n",cpu); return 0; }
在我的电脑(老爷机)上运行的效果:
注:cpuid参数有很多, 这里只取了品牌信息.