0

Opcode prefix can be duplicated. For example, let's take 8B opcode (mov) with operand size override prefix:

66 66 66 66 66 8B 00 

visual studio disassembler's output (x64 mode):

mov ax, word ptr [rax] 

Now, let's take this one:

66 66 66 66 67 8B 00 

visual studio disassembler's output:

mov ax, word ptr [eax] 

And this one:

66 66 66 67 /*it throws away left side*/ 67 8B 00 

visual studio disassembler's output:

?? ?? ?? ?? mov eax, dword ptr [eax] 

So, I want to ask why prefix 67 can't be duplicated. Is it visual studio specific processing that does not match hardware semantics or cpu itself does not allow this?

3
  • Duplicating prefixes is undefined behavior. That said, I don't know why the VS disassemble does what it does. ndisasm and objdump, for example, decode that as expected. Commented Jun 5, 2015 at 10:26
  • "You could only form an infinitely long instruction by using redundant prefixes in front on the opcodes". "For example, you can take the innocuous looking instruction: 89 E5 mov %sp,%bp and turn it into a really long instruction: 66 66 66 66 … 66 66 89 E5 mov %sp,%bp" Commented Jun 5, 2015 at 11:09
  • @LưuVĩnhPhúc You can't have infinite prefixes. While I don't believe duplicate "classic" prefixes results in undefined behaviour, gas uses them for long NOPs, a total instruction length greater than 15 does. Commented Jun 5, 2015 at 15:46

1 Answer 1

1

It seems VS simply does not support this. With ndisasm (the disassembler of nasm), it just works well, it is diassembled as:

6767668B00 mov ax,[eax] 

The problem with this is however, in a normal 64 bit environment, addressing using only the lower 32 bit is normally not possible.

But I tested with:

 67674889D8 mov rax,rbx 

and the CPU (i7-4770) executed it without an exception.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.