*/ mov a, EAX; mov b, EBX; mov c, ECX; mov d, EDX; } printf ("InfoType %x\nEAX: %x\nEBX: %x\nECX: %x\nEDX: %x\n", i, a, b, c, d); return 0; } If either version was written in plain assembly language, the programmer must manually save the results of EAX, EBX, ECX, and EDX elsewhere if they want to keep using the values. Wrapper functions GCC also provides a header called <cpuid.h> on systems that have CPUID. The __cpuid is a macro expanding to inline assembly. Typical usage would be: #include <stdio.h> #include <cpuid.h> int main() { unsigned int eax, ebx, ecx, edx; __cpuid(0 /* vendor string */, eax, ebx, ecx, edx); printf("EAX: %x\nEBX: %x\nECX: %x\nEDX: %x\n", eax, ebx, ecx, edx); return 0; } But if one requested an extended feature not present on this CPU, they would not notice and might get random, unexpected results. Safer version is also provided in <cpuid.h>. It checks for extended features and does some more safety checks. The output values are not passed using reference-like macro parameters, but more conventional pointers. #include <stdio.h> #include <cpuid.h> int main() { unsigned int eax, ebx, ecx, edx; /* 0x81234567 is nonexistent, but assume it exists */ if (!__get_cpuid (0x81234567, &eax, &ebx, &ecx, &edx)) { printf("Warning: CPUID request 0x81234567 not valid!\n"); return 1; } printf("EAX: %x\nEBX: %x\nECX: %x\nEDX: %x\n", eax, ebx, ecx, edx); return 0; } Notice the ampersands in &a, &b, &c, &d and the conditional statement. If the __get_cpuid call receives a correct request, it will return a non-zero value, if it fails, zero. Microsoft Visual C compiler has builtin function __cpuid() so the cpuid instruction may be embedded without using inline assembly, which is handy since the x86-64 version of MSVC does not allow inline assembly at all. The same program for MSVC would be: #include <stdio.h> #ifdef #include <intrin.h> #endif int main() { unsigned int regs[4]; int i; for (i = 0; i < 4; i++) { __cpuid(regs, i); printf("The code %d gives %d, %d, %d, %d", regs[0], regs[1], regs[2], regs[3]); } return 0; } Many interpreted or compiled scripting languages are capable of using CPUID via an FFI library. One such implementation shows usage of the Ruby FFI module to execute assembly language that includes the CPUID opcode. .NET 5 and later versions provide the System.Runtime.Intrinsics.X86.X86base.CpuId method. For instance, the C# code below prints the processor brand if it supports CPUID instruction:using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86;