Byte Encoding Order x86 Bytes

I know that x86 instructions can contain a maximum of 4 bytes of prefixes like Lock, rep, redefining segments, etc.

Is there any specific order in which they should appear in case of using multiple prefixes?

+7
source share
3 answers

the order can be found in volume 2A of the Intel Software Development Guide.

In a nutshell:

  • the prefixes F2 and F3 cancel each other. The one that comes later takes precedence.
  • prefix 66 ignored if F2 or F3 .
  • the REX escape code may not be followed by any other prefixes.
  • VEX escape cannot be preceded by REX, 66 , F2 or F3

for the rest, order should not matter.

+5
source

Quote from Intelยฎ 64 and IA-32 Software Development Guide. Volume 2A: Instruction Manual Reference, AM

The instruction prefixes are divided into four groups, each of which has a set of valid prefix codes. For each instruction, this is only useful for include up to one prefix code from each of the four groups (groups 1, 2, 3, 4). Groups 1 to 4 can be placed in any order relative to each other.

+1
source

The scope of the architecture of Intel developers' manuals describes the layout in detail, but from what I remember the last time I read it, the order for most did not matter, except for the REX / REX.W , which should occupy the slot closest to the beginning actual bytes of the command (otherwise it takes up a slot more on the right)

+1
source

All Articles