Determine CPUID as listed in the Intel Intrinsics Guide

≡放荡痞女 提交于 2019-12-04 06:58:50

you can get that information using CPUID instruction, where

The extended family, bit positions 20 through 27 are used in conjunction with the family code, specified in bit positions 8 through 11, to indicate whether the processor belongs to the Intel386, Intel486, Pentium, Pentium Pro or Pentium 4 family of processors. P6 family processors include all processors based on the Pentium Pro processor architecture and have an extended family equal to 00h and a family code equal to 06h. Pentium 4 family processors include all processors based on the Intel NetBurst® microarchitecture and have an extended family equal to 00h and a family code equal to 0Fh.

The extended model specified in bit positi ons 16 through 19, in conjunction with the model number specified in bits 4 though 7 are used to identify the model of the processor within the processor’s family.

see page 22 in Intel Processor Identification and the CPUID Instruction for futher details.

Actual CPUID is then "family_model". The following code should do the job:

#include "stdio.h"

int main () {

  int ebx = 0, ecx = 0, edx = 0, eax = 1;
  __asm__ ("cpuid": "=b" (ebx), "=c" (ecx), "=d" (edx), "=a" (eax):"a" (eax));

  int model = (eax & 0x0FF) >> 4;
  int extended_model = (eax & 0xF0000) >> 12;
  int family_code = (eax & 0xF00) >> 8;
  int extended_family_code = (eax & 0xFF00000) >> 16;

  printf ("%x %x %x %x \n", eax, ebx, ecx, edx);
  printf ("CPUID: %02x %x\n", extended_family_code | family_code, extended_model | model);
  return 0;
}

For my computer I get:

CPUID: 06_25

hope it helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!