x86asm汇编读取cpu信息(cpuid指令)

陪她去流浪 桃子 2013年11月06日 阅读次数:2039

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参数有很多, 这里只取了品牌信息.

这篇文章的内容已被作者标记为“过时”/“需要更新”/“不具参考意义”。

标签:汇编 · x86asm