Reputation:
In instruction encoding Default sizes are:
operand size is 32 bit
address size is 64 bit
We can use the legacy prefix:
0x66 – Operand-size override prefix
to make operand size 16. What if I want to make it 8 bits not 16?
Upvotes: 0
Views: 371
Reputation: 57922
What if I want to make it 8 bits not 16?
You can't do this with prefixes. Instructions that support an 8-bit operand size do so with an entirely separate opcode, not with an override prefix.
For instance:
0: 01 d9 addl %ebx,%ecx
2: 66 01 d9 addw %bx,%cx
5: 00 d9 addb %bl,%cl
The 32-bit add
is opcode 01
, with a mod/rm byte of d9
. The 16-bit add is identical but with the 66
operand size prefix. However the 8-bit add is opcode 00
instead.
The explanation for this is historical. The 16-bit 8086 CPU supported 8-bit and 16-bit operands, and used separate opcodes for the two: 00
for addb
and 01
for addw
. (This is still what you get when you run a modern chip in real mode, like in a boot sector.) The 32-bit 80386 wanted to add 32-bit operands while still supporting both 8 and 16, but there was no room for so many more opcodes, so for 32-bit protected mode they made all the formerly 16-bit instructions act as 32-bit instead, with an override available to go back to 16 bit, and they left the 8-bit instructions alone. (In real mode the operand size override has the opposite effect: 01
is addw
and 66 01
is addl
.)
Upvotes: 3