Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>cpuid</code> instruction, used with <code>EAX=0</code> will return a 12-character vendor string in <code>EBX</code>, <code>EDX</code>, <code>ECX</code>, in that order.</p> <p>For Intel, this string is "GenuineIntel". For AMD, it's "AuthenticAMD". Other companies that have created x86 chips have their own strings.The <a href="http://en.wikipedia.org/wiki/CPUID" rel="noreferrer">Wikipedia page</a> for <code>cpuid</code> has many (all?) of the strings listed, as well as an example ASM listing for retrieving the details.</p> <p>You really only need to check if ECX matches the last four characters. You can't use the first four, because some Transmeta CPUs also start with "Genuine"</p> <ul> <li>For Intel, this is <code>0x6c65746e</code></li> <li>For AMD, this is <code>0x444d4163</code></li> </ul> <p>If you convert each byte in those to a character, they'll appear to be backwards. This is just a result of the little endian design of x86. If you copied the register to memory and looked at it as a string, it would work just fine.</p> <p>Example Code:</p> <pre><code>bool IsIntel() // returns true on an Intel processor, false on anything else { int id_str; // The first four characters of the vendor ID string __asm__ ("cpuid":\ // run the cpuid instruction with... "=c" (id_str) : // id_str set to the value of EBX after cpuid runs... "a" (0) : // and EAX set to 0 to run the proper cpuid function. "eax", "ebx", "edx"); // cpuid clobbers EAX, ECX, and EDX, in addition to EBX. if(id_str==0x6c65746e) // letn. little endian clobbering of GenuineI[ntel] return true; else return false; } </code></pre> <p>EDIT: One other thing - this can easily be changed into an <code>IsAMD</code> function, <code>IsVIA</code> function, <code>IsTransmeta</code> function, etc. just by changing the magic number in the <code>if</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload