Adjust RPL Field of Segment Selector

Encoding

EncodingOperand 1Operand 2
mrModRM.r/m[rw]ModRM.reg[r]

Description

The ARPL instruction compares the RPL (requested privilege level) field (bits 0 and 1) of two segment selectors. The the RPL field of the destination operand is less than the RPL field of the source operand, ZF is set, and the RPL field of the destination is increased to match the source's. Otherwise, ZF is cleared and no change to the destination occurs.

This instruction is not encodable in Long Mode, and, if encountered, will be interpreted as MOVSXD.

Operation

public void ARPL(U16 dest, U16 src)
{
    if (dest.Bit[0..1] < src.Bit[0..1])
        dest.Bit[0..1] = src.Bit[0..1];
}

Flags Affected

CF (carry flag)
Unmodified.
PF (parity flag)
Unmodified.
AF (auxiliary flag)
Unmodified.
ZF (zero flag)
Set if an adjustment is made. Cleared otherwise.
SF (sign flag)
Unmodified.
OF (overflow flag)
Unmodified.

Exceptions

Protected Mode

#UD
  • If the LOCK prefix is used.
#SS(0)
  • If a memory operand using the SS segment has an effective address that is outside the SS segment's limit.
#GP(0)
  • If the destination is located in a non-writable segment.
  • If a memory operand uses a segment containing a NULL selector.
  • If a memory operand (using a segment other than SS) has an effective address that is outside the segment's limit.
#PF(fc)
  • If a page fault occurs.
#AC(0)
  • If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.

Compatibility Mode

#UD
  • If the LOCK prefix is used.
#SS(0)
  • If a memory operand using the SS segment has an effective address that is outside the SS segment's limit.
#GP(0)
  • If the destination is located in a non-writable segment.
  • If a memory operand uses a segment containing a NULL selector.
  • If a memory operand (using a segment other than SS) has an effective address that is outside the segment's limit.
#PF(fc)
  • If a page fault occurs.
#AC(0)
  • If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.