ADCX: Unsigned Integer Addition of Two Operands with Carry Flag

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeCPUID Feature FlagDescription
66 0F 38 F6 /r
ADCX r32, r/m32
RMInvalidValidValidADXUnsigned addition of r32 with carry flag and r/m32 to r32.
66 REX.W 0F 38 F6 /r
ADCX r64, r/m64
RMNot EncodableNot EncodableValidADXUnsigned addition of r64 with carry flag and r/m64 to r64.

Encoding

EncodingOperand 1Operand 2
RMModRM.reg[rw]ModRM.r/w[r]

Description

The ADCX instruction adds the destination operand, the source operand, and the CF flag and stores the result in the destination operand.

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 of Two Operands with Overflow Flag)).

In 64 bit mode, the default operand size is 32 bits, but REX.W will change it to 64 bits.

Operation

This pseudo-code uses C# syntax. A list of the types used is available here.
public void ADCX_32(ref uint dest, uint src) {
  dest = dest + src + CF;
}
public void ADCX_64(ref ulong dest, ulong src) {
  dest = dest + src + CF;
}

Flags Affected

CF (carry flag)
Set according to the result.
PF (parity flag)
Unmodified.
AF (auxiliary flag)
Unmodified.
ZF (zero flag)
Unmodified.
SF (sign flag)
Unmodified.
OF (overflow flag)
Unmodified.

C Intrinsics

Exceptions

Protected Mode

#UD
If the LOCK prefix is used.
If CPUID.(EAX=07h,ECX=00h):EBX.ADX[bit 19] is 0.
#SS(0)
For an illegal address in the SS segment.
#GP(0)
For an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments.
If the DS, ES, FS, or GS register is used to access memory and it contains a NULL segment selector.
#PF(fault-code)
If a page fault occurs.
#AC(0)
If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.

Real-Address Mode

#UD
If the LOCK prefix is used.
If CPUID.(EAX=07h,ECX=00h):EBX.ADX[bit 19] is 0.
#SS(0)
For an illegal address in the SS segment.
#GP(0)
If any part of the operand lies outside the effective address space from 0 to 0xFFFF.

Virtual-8086 Mode

#UD
If the LOCK prefix is used.
If CPUID.(EAX=07h,ECX=00h):EBX.ADX[bit 19] is 0.
#SS(0)
For an illegal address in the SS segment.
#GP(0)
If any part of the operand lies outside the effective address space from 0 to 0xFFFF.
#PF(fault-code)
If a page fault occurs.
#AC(0)
If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.

Compatibility Mode

Same exceptions as in protected mode.

Long Mode

#UD
If the LOCK prefix is used.
If CPUID.(EAX=07h,ECX=00h):EBX.ADX[bit 19] is 0.
#SS(0)
If a memory address referencing the SS segment is in non-canonical form.
#GP(0)
If the memory address is in a non-canonical form.
#PF(fault-code)
If a page fault occurs.
#AC(0)
If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.