Unsigned Integer Addition With Carry Flag

Encoding

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

Description

The ADCX instruction adds the source operand, the destination operand, and the carry flag. The result is stored in the destination operand. Only the carry flag is affected.

This instruction is designed for use in multibyte additions such as in arbitrary precision arithmetic. The difference between this instruction and ADC (Add with Carry) is that this one allows the creation of two "carry chains" – one using CF (this one) and one using OF (ADOX (Unsigned Integer Addition with Overflow Flag)).

Operation

public void ADCX(ref U32 dest, U32 src)
{
    dest += src + EFLAGS.CF;
}

public void ADCX(ref U64 dest, U64 src)
{
    dest += src + EFLAGS.CF;
}

Examples

Flags Affected

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

Intrinsics

Exceptions

Real-Address Mode

#UD
  • If the LOCK prefix is used, but the destination is not a memory operand.
#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 a memory operand (using a segment other than SS) has an effective address that is outside the segment's limit.

Virtual-8086 Mode

#UD
  • If the LOCK prefix is used, but the destination is not a memory operand.
#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 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.

Protected Mode

#UD
  • If the LOCK prefix is used, but the destination is not a memory operand.
#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, but the destination is not a memory operand.
#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.

Long Mode

#UD
  • If the LOCK prefix is used, but the destination is not a memory operand.
#SS(0)
  • If a memory operand using the SS segment is in non-canonical form.
  • If a memory operand using the SS segment has an effective address that is outside the SS segment's limit.
#GP(0)
  • If a memory operand (using a segment other than SS) is in non-canonical form.
  • 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.