My question is what is the difference in CPUID
work on 32-bit and 64-bit machines? Maybe there are some differences in the way we call CPUID
or the way it returns the result, like, we should check RAX
and other registers, maybe the information stored in them is different
Asked
Active
Viewed 153 times
0

Peter Cordes
- 328,167
- 45
- 605
- 847

ans
- 378
- 1
- 5
- 18
1 Answers
3
according to Intel SDM
the instruction is operate the same for both 64b and non-64b
but even though that it's behave the same, keep in mind that CPUID instruction clears the high 32 bits of the RAX/RBX/RCX/RDX registers in all modes, so if you check the highest 32 bits in the registers mention above you will read 0x0.
And since CPUID is looking at EAX (and ECX in some cases) both codes below will return same data :
mov RAX, 0xFFFF_FFFF_0000_000
cpuid
mov RAX, 0x0
cpuid

Matt. Stroh
- 904
- 7
- 16
-
1https://www.felixcloutier.com/x86/cpuid has instruction listings scraped from Intel's PDFs. [Writing a 32-bit register *always* zero-extends to the full 64-bit register](https://stackoverflow.com/questions/11177137/why-do-x86-64-instructions-on-32-bit-registers-zero-the-upper-part-of-the-full-6), including when CPUID writes them. (As you say, even in 32-bit mode and then you later switch to 64-bit mode so you can read the full regs) – Peter Cordes Feb 20 '23 at 07:49