MOV

Move to

Opcode/InstructionOp/En64-Bit ModeCompat/Leg ModeDescription
0F 21/r MOV r32, DR0–DR7MRN.E.ValidMove debug register to r32.
0F 21/r MOV r64, DR0–DR7MRValidN.E.Move extended debug register to r64.
0F 23 /r MOV DR0–DR7, r32RMN.E.ValidMove r32 to debug register.
0F 23 /r MOV DR0–DR7, r64RMValidN.E.Move r64 to extended debug register.

Instruction Operand Encoding

Op/EnOperand 1Operand 2Operand 3Operand 4
MRModRM:r/m (w)ModRM:reg (r)N/AN/A
RMModRM:reg (w)ModRM:r/m (r)N/AN/A

Description

Moves the contents of a debug register (DR0, DR1, DR2, DR3, DR4, DR5, DR6, or DR7) to a general-purpose register or vice versa. The operand size for these instructions is always 32 bits in non-64-bit modes, regardless of the operand-size attribute. (See Section 18.2, “Debug Registers”, of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A, for a detailed description of the flags and fields in the debug registers.)

The instructions must be executed at privilege level 0 or in real-address mode.

When the debug extension (DE) flag in register CR4 is clear, these instructions operate on debug registers in a manner that is compatible with Intel386 and Intel486 processors. In this mode, references to DR4 and DR5 refer to DR6 and DR7, respectively. When the DE flag in CR4 is set, attempts to reference DR4 and DR5 result in an undefined opcode (#​​​UD) exception. (The CR4 register was added to the IA-32 Architecture beginning with the Pentium processor.)

At the opcode level, the reg field within the ModR/M byte specifies which of the debug registers is loaded or read. The two bits in the mod field are ignored. The r/m field specifies the general-purpose register loaded or read.

In 64-bit mode, the instruction’s default operation size is 64 bits. Use of the REX.B prefix permits access to additional registers (R8–R15). Use of the REX.W or 66H prefix is ignored. Use of the REX.R prefix causes an invalid-opcode exception. See the summary chart at the beginning of this section for encoding data and limits.

Operation

IF ((DE = 1) and (SRC or DEST = DR4 or DR5))
    THEN
        #​​​UD;
    ELSE
        DEST := SRC;
FI;

Flags Affected

The OF, SF, ZF, AF, PF, and CF flags are undefined.

Protected Mode Exceptions

#​​​​GP(0)If the current privilege level is not 0.
#​​​UDIf CR4.DE[bit 3] = 1 (debug extensions) and a MOV instruction is executed involving DR4 or DR5.
If the LOCK prefix is used.
#​DBIf any debug register is accessed while the DR7.GD[bit 13] = 1.

Real-Address Mode Exceptions

#​​​UDIf CR4.DE[bit 3] = 1 (debug extensions) and a MOV instruction is executed involving DR4 or DR5.
If the LOCK prefix is used.
#​DBIf any debug register is accessed while the DR7.GD[bit 13] = 1.

Virtual-8086 Mode Exceptions

#​​​​GP(0)The debug registers cannot be loaded or read when in virtual-8086 mode.

Compatibility Mode Exceptions

Same exceptions as in protected mode.

64-Bit Mode Exceptions

#​​​​GP(0)If the current privilege level is not 0.
If an attempt is made to write a 1 to any of bits 63:32 in DR6.
If an attempt is made to write a 1 to any of bits 63:32 in DR7.
#​​​UDIf CR4.DE[bit 3] = 1 (debug extensions) and a MOV instruction is executed involving DR4 or DR5.
If the LOCK prefix is used.
If the REX.R prefix is used.
#​DBIf any debug register is accessed while the DR7.GD[bit 13] = 1.

This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be incomplete or broken in various obvious or non-obvious ways. Refer to Intel® 64 and IA-32 Architectures Software Developer’s Manual for anything serious.