0

In Intel Software Developer's Manual, Volume 2B, page 4-540, the assembly RDPID instruction is presented.

Opcode/Instruction
F3 0F C7 /7
RDPID r32

Op/En
R

64/32-bit Mode
N.E./V

CPUID Feature Flag
RDPID

Description
Read IA32_TSC_AUX into r32.

Opcode/Instruction
F3 0F C7 /7
RDPID r64

Op/En
R

64/32-bit Mode
V/N.E.

CPUID Feature Flag
RDPID

Description
Read IA32_TSC_AUX into r64.

and then

Instruction Operand Encoding

Op/En
R

Operand 1
ModRM:r/m (w)

Operand 2
N/A

Operand 3
N/A

Operand 4
N/A

I am not familiar with the conventions adopted and, from the table, I can't understand the syntax of the instruction. The only thing I can guess is that the opcode is the same for 32 and 64 bit mode, so maybe the instruction is the same in both cases. Also, the instruction is read-only (maybe this is the R in Op/En).

But what about the rest? I tried

rdpid <destination_register>

and it seems to work. Also CS.D and REX.W are mentioned, which I don't know (and a search through the manual for REX.W was unuseful, I couldn't find an explanation). Why isn't Operand 1 the destination register? And what is ModRM:r/m (w)?

So, the actual question: which is the correct syntax for this instruction and how to get it from the information provided in the manual?

BowPark
  • 1,340
  • 2
  • 21
  • 31
  • 2
    Operand 1 *is* the destination register. Note the "ModRM.MOD = 011B" which means the R/M field encodes a register-direct mode, not a memory addressing mode. See also [How to read the Intel Opcode notation](https://stackoverflow.com/a/53976236) / [x64 instruction encoding and the ModRM byte](https://stackoverflow.com/q/15511482) / [x86\_64 Opcode encoding formats in the intel manual](https://stackoverflow.com/q/57440527) / [How to determine if ModR/M is needed through Opcodes?](https://stackoverflow.com/q/55312459) – Peter Cordes May 09 '23 at 17:10
  • @PeterCordes Thank you so much for all the references, they are very useful. – BowPark May 10 '23 at 08:42

1 Answers1

4

CS.D is the D bit in the segment descriptor referenced by CS, indicating if this is a 16 or 32/64 bit code segment. REX.W is the W bit in the REX family of prefixes (40h to 4Fh) indicating 64-bit operand size.

The instruction is described as

F3 0F C7 /7    RDPID r32  (in 16/32 bit mode)
F3 0F C7 /7    RDPID r64  (in 64 bit mode)

The notation /7 means “a modr/m byte with 7 in the reg field.” The notation r32 and r64 means “a general purpose register of 32 or 64 bits respectively.” From the “instruction operand encoding” table you can learn that this operand is encoded in the r/m field of the modr/m byte. Thus, in 32-bit mode you can e.g. use the instruction like this:

F3 0F CF    RDPID ECX

and in 64-bit mode like this:

F3 0F CF    RDPID RCX
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
fuz
  • 88,405
  • 25
  • 200
  • 352