Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1069664
  • 博文数量: 252
  • 博客积分: 4561
  • 博客等级: 上校
  • 技术积分: 2833
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-15 08:23
文章分类

全部博文(252)

文章存档

2015年(2)

2014年(1)

2013年(1)

2012年(16)

2011年(42)

2010年(67)

2009年(87)

2008年(36)

分类: LINUX

2009-09-15 14:47:42

#include <stdio.h>

int main(void)
{
        unsigned int eax = 0, edx = 0, ecx = 0;

        asm volatile ("cpuid"
                      : "=a"(eax), "=d"(edx)
                      : "a"(0x01)
                      );

        if (edx & (1 << 17))
        {
                /* edx输出中间32位的序列号,ecx输出最低32位的序列号 */
                asm volatile ("cpuid"
                              : "=c"(ecx), "=d"(edx)
                              : "a"(0x03)
                              );

                printf("Serial Number : %04x-%04x-%04x-%04x-%04x-%04x\n",
                        eax >> 16, eax << 16,
                        edx >> 16, edx << 16,
                        ecx >> 16, ecx << 16);

        }
        else
        {
                printf("no support cpu serial number.\n");
        }

        return 0;
}

阅读(562) | 评论(0) | 转发(0) |
0

上一篇:get cpuid 序列号

下一篇:get cpuid 序列号

给主人留下些什么吧!~~