Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cpuid.h>
- #include <stdio.h>
- enum {
- CONST4b = 0b1111,
- CONST4 = 4,
- CONST2b = 0b11,
- CONST8b = 0b11111111,
- CONST8 = 8,
- CONST6 = 6,
- CONST15 = 15
- };
- int main() {
- int v1, v2, v3;
- __asm__("mov $1, %%eax\n\t"
- "cpuid"
- : "=a"(v1), "=c"(v2), "=d"(v3)
- :
- : "ebx");
- // int stepping_id = v1 && CONST4b;
- v1 = (v1 >> CONST4);
- int model = v1 & CONST4b;
- v1 = (v1 >> CONST4);
- int family_id = v1 & CONST4b;
- v1 = (v1 >> CONST4);
- // int processor_type = v1 & CONST2b;
- v1 = (v1 >> CONST4);
- int extended_model_id = v1 & CONST4b;
- v1 = (v1 >> CONST4);
- // int extended_family_id = v1 & CONST8b;
- v1 = (v1 >> CONST8);
- int processor_model = 0;
- if (family_id == CONST6 || family_id == CONST15) {
- processor_model = (extended_model_id << CONST4) + model;
- } else {
- processor_model = model;
- }
- printf("family=%d model=%d ecx=0x%x edx=0x%x\n", family_id, processor_model,
- v2, v3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement