order for encoding x86 instruction prefix bytes

后端 未结 3 2598
一个人的身影
一个人的身影 2021-02-20 18:33

I know that x86 instructions can have a maximum of 4 bytes of prefixes, e.g Lock, rep, segment overrides etc.

Is there any particular order in which they should appear,

3条回答
  •  伪装坚强ぢ
    2021-02-20 18:42

    the order can be found in volume 2A of the Intel Software Developer's Manual.

    In a nutshell:

    • the F2 and F3 prefixes cancel each other out. The one that comes later has precedence.
    • the 66 prefix is ignored if either F2 or F3 are used (as mandatory prefixes in a long instruction). This of course doesn't apply to rep movsw where both those prefixes are simply prefixes, not part of the opcode.
    • the REX escape may not be followed by any other prefixes.
    • the VEX escape may not be preceded by REX, 66, F2 or F3

    for the rest, the order shouldn't matter.

提交回复
热议问题