Operand-size and address-size override prefix

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
freecrac
Member
Member
Posts: 69
Joined: Thu Sep 20, 2012 5:11 am
Location: germany hamburg

Operand-size and address-size override prefix

Post 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
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Operand-size and address-size override prefix

Post 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
freecrac
Member
Member
Posts: 69
Joined: Thu Sep 20, 2012 5:11 am
Location: germany hamburg

Re: Operand-size and address-size override prefix

Post 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
Post Reply