Opcode | Encoding | 16-bit | 32-bit | 64-bit | CPUID Feature Flag(s) | Description |
---|---|---|---|---|---|---|
66 0F 38 F6 /r ADCX r32, r/m32 | rm | Valid | Valid | Valid | adx | Add r32, the carry flag, and r/m32 into r32. Sets only the carry flag for overflow. |
66 REX.W 0F 38 F6 /r ADCX r64, r/m64 | rm | N/E | N/E | Valid | adx | Add r64, the carry flag, and r/m64 into r64. Sets only the carry flag for overflow. |
Encoding
Encoding | Operand 1 | Operand 2 |
---|---|---|
rm | ModRM.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
uint8_t _addcarryx_u32(uint8_t c_in, uint32_t src1, uint32_t src2, uint32_t *sum_out)
uint8_t _addcarryx_u64(uint8_t c_in, uint64_t src1, uint64_t src2, uint64_t *sum_out)
Exceptions
Exception | Mode | Cause of Exception | |||
---|---|---|---|---|---|
Real Mode | Virtual 8086 | Protected and Compatibility | Long Mode | ||
#UD | X | X | X | X | If the LOCK prefix is used. |
#SS(0) | X | X | X | X | If a memory operand using the SS segment has an effective address that is outside the SS segment's limit. |
X | If a memory operand using the SS segment is in non-canonical form. | ||||
#GP(0) | X | X | X | X | If a memory operand (using a segment other than SS ) has an effective address that is outside the segment's limit. |
X | X | If the destination is located in a non-writable segment. | |||
X | X | If a memory operand uses a segment containing a NULL selector. | |||
X | If a memory operand (using a segment other than SS ) is in non-canonical form. | ||||
#PF(fc) | X | X | X | If a page fault occurs. | |
#AC(0) | X | X | X | If alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made. |