Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 30 lines (28 sloc) 0.495 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include <stdint.h>

void cpuid(uint32_t eax, uint32_t ecx, uint32_t regs[4])
{
asm volatile (
#ifdef __i386__
"push %%ebx\n\t"
"push %%edx\n\t"
#else
"push %%rbx\n\t"
"push %%rdx\n\t"
#endif
"cpuid\n\t"
"mov %%eax,(%4)\n\t"
"mov %%ebx,4(%4)\n\t"
"mov %%ecx,8(%4)\n\t"
"mov %%edx,12(%4)\n\t"
#ifdef __i386__
"pop %%edx\n\t"
"pop %%ebx\n\t"
#else
"pop %%rdx\n\t"
"pop %%rbx\n\t"
#endif
: "=a" (eax), "=c" (ecx)
: "0" (eax), "1" (ecx), "S" (regs)
: "memory"
);
}
Something went wrong with that request. Please try again.