Reputation: 1095
How does the processor differentiate between these two instructions?
81 /2 iw - Add with carry imm16 to r/m16.
81 /2 id - Add with carry imm32 to r/m32.
The only thing different I can see in the instruction is the size of the immediate value and that isn't enough, right? I mean if the immediate is two bytes an instruction could be right after it and the processor wouldn't know if it was 4 bytes of immediate or 2 bytes and another instruction.
Also am I supposed to add a REX prefix to these for 64-bit operation or just REX.R for the 9-16 registers?
Upvotes: 0
Views: 248
Reputation: 64913
Mode and operand size prefix. In 16 bit mode, 81 /2 will be adc rm16, imm16
. In 32 or 64 bit mode, it will be adc rm32, imm32
. Unless you add the operand size override, then they switch places.
To make it adc rm64, imm32
(there is no adc rm64, imm64
), it needs an REX.W prefix, REX.R is useless since there is no r operand, REX.B/X will just allow you to use extended registers as (part of) the rm operand, and don't change the operand size. So for example adc r8d, 0xDEADBEEF
is valid and would be 41 81 D0 EF BE AD DE
.
Upvotes: 1