x86xoropcode

x86 opcodes for the xor instruction, cannot find detail required in manuals


Some instructions with corresponding opcodes:

xor eax, eax     \x31\xc0
xor ecx, ecx     \x31\xc9
xor edx, edx     \x31\xd2 
xor ebx, ebx     \x31\xdb

Could someone please explain the calculation behind the second byte (it increases in steps of 9 down the list) and the reason for the \xc0 'base'?


Solution

  • The two most significant bits (6 and 7) of this byte correspond to the MOD field. When they both are 1, the register addressing mode is enabled, and other 6 bits determine two registers (3 bits per one register):