Page 1 of 1

Operand-size and address-size override prefix

Posted: Thu Feb 06, 2014 9:04 am
by freecrac
Hello,
in the Wiki-table for the "Operand-size and address-size override prefix" we can find that the "0x66 operand prefix" and the "0x67 address prefix" is N/A (not aviable) for the real mode and the virtual 8086 mode. http://wiki.osdev.org/X86-64_Instruction_Encoding

But now i am wondering how somebody is switching from the 16 bit RM to the PM on a 80386+ and doing an access of the 32 bit controllregister cr0, but without to use an operandsize prefix before we are switching to the PM with a far jump? :shock:
Example: 66 0F 22 C0 mov cr0,eax

Has nobody tested it before on a 80386+ in the realmode to reverse the default operand-size and address-size, i can not believe.

Hint: Inside of the Intel manual we can find this statement: "These prefixes can be used in real-address mode as well as in protected mode and virtual-8086 mode". And inside the AMD manual we can find this statement: "An address-size override can be used in real-address mode to enable 32-bit addressing; however, the maximum allowable 32-bit linear address is still 000FFFFFH."

Dirk

Re: Operand-size and address-size override prefix

Posted: Thu Feb 06, 2014 9:51 am
by bluemoon
MOV to control register has dedicated opcode, it always work with r32 in real mode and does not require prefix.
In 64-bit long mode you may prefix it with REX.R and move to/from 64-bit register.
Intel manual wrote: The operand size for these instructions is always 32 bits in non-64-bit modes, regardless of the operand-size attribute

Re: Operand-size and address-size override prefix

Posted: Thu Feb 06, 2014 11:15 am
by freecrac
bluemoon wrote:MOV to control register has dedicated opcode, it always work with r32 in real mode and does not require prefix.
In 64-bit long mode you may prefix it with REX.R and move to/from 64-bit register.
Intel manual wrote: The operand size for these instructions is always 32 bits in non-64-bit modes, regardless of the operand-size attribute
Aha, thank you. I try it later to place a nop-byte instead.

But for other instructions on a 80386+ within the 16 bit real mode the instruction prefixes for to reverse the default operand- and address- size are aviable and will not be ignored.

Dirk