1

I'm reading https://www.felixcloutier.com/x86/mov (mov as example) and there are these opcodes in the tables like 88 /r and REX + 88 /r and even REX.W + 8C /r. I couldn't find an explanation at the website. What does r, REX, REX.W, and 8C mean? How do I come up with the hex value for an entire mov instruction based on this table?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • 4
    did you try reading documents from Intel on the instruction set? – old_timer Jan 07 '20 at 05:50
  • You might be interested in this related [walk through](https://stackoverflow.com/a/28665062/547981) as well. – Jester Jan 07 '20 at 11:26
  • 1
    felixcloutier/x86 and other similar sites scrape only the instruction entries from Intel's vol.2 PDF, omitting the appendices and intro sections that tell you how to read an entry. Go read the original. – Peter Cordes Jan 07 '20 at 13:17
  • Does this answer your question? [How to read the Intel Opcode notation](https://stackoverflow.com/questions/15017659/how-to-read-the-intel-opcode-notation) – phuclv Jan 07 '20 at 13:31

1 Answers1

4

Intel® 64 and IA-32 Architectures Developer's Manual: Vol. 2A, section 2.2.1 gives the answer to your question.

REX prefixes are instruction-prefix bytes used in 64-bit mode. They do the following:

  • Specify GPRs and SSE registers.
  • Specify 64-bit operand size.
  • Specify extended control registers.

Particularities are given in Section 2.2.1.2:

  • Setting REX.W can be used to determine the operand size but does not solely determine operand width.
  • REX.R modifies the ModR/M reg field when that field encodes a GPR, SSE, control or debug register.
  • REX.X bit modifies the SIB index field.
  • REX.B either modifies the base in the ModR/M r/m field or SIB base field; or it modifies the opcode reg field used for accessing GPRs.

Please further refer to the Intel’s manual on how exactly they are encoded.

According to Section 3.1.1.1,

/r — Indicates that the ModR/M byte of the instruction contains a register operand and an r/m operand.

The ModR/M byte is explaned in section 2.1 of the Manual. 88, 89, 8A, 8B, 8C, etc. are just opcode bytes also explained in this section of the Manual.

Maxim Masiutin
  • 3,991
  • 4
  • 55
  • 72