I am experimenting with SIB byte, by writing this simple instruction, save it in a file and compile as flat binary format:
jmp [ecx*2]
But then, the generated code is (from the output of hexdump):
00000000 67 ff 24 09 |g.$.|
0x67 is the address-override prefix.
0xff is the opcode for jmp instruction.
0x24 is the ModR/M byte that indicates an SIB byte follows.
finally, the SIB byte value 0x09 is equivalent to [ECX] addressing mode, while my code is [ecx*2]
, according to table 2-3 in Intel's manual volume 2, instruction reference.
For ecx*4 and ecx*8, it works correctly. For example:
jmp [ecx*4]
The generated code is:
00000000 67 ff 24 8d |g.$.|
0x8d is equivalent to [ECX*4].