Add With Carry

Encoding

EncodingOperand 1Operand 2
mrModRM.r/m[rw]ModRM.reg[r]
rmModRM.reg[rw]ModRM.r/m[r]
aiAL/AX/EAX/RAXimm8/16/32
miModRM.r/m[rw]imm8/16/32

Description

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

This instruction is designed for use in multiword additions such as in arbitrary precision arithmetic.

This instruction can be used with the LOCK prefix to allow atomic exectution.

Operation

// `src` is sign extended to the width of `dest`

public void ADC(ref U8 dest, U8 src)
{
    dest += src + CF;
}
public void ADC(ref U16 dest, U16 src)
{
    dest += src + CF;
}
public void ADC(ref U32 dest, U32 src)
{
    dest += src + CF;
}
public void ADC(ref U64 dest, U64 src)
{
    dest += src + CF;
}

Flags Affected

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

Intrinsics

Exceptions

ExceptionModeCause of Exception
Real
Mode
Virtual
8086
Protected and CompatibilityLong
Mode
#UDXXXXIf the LOCK prefix is used, but the destination is not a memory operand.
#SS(0)XXXXIf a memory operand using the SS segment has an effective address that is outside the SS segment's limit.
XIf a memory operand using the SS segment is in non-canonical form.
#GP(0)XXXXIf a memory operand (using a segment other than SS) has an effective address that is outside the segment's limit.
XXIf the destination is located in a non-writable segment.
XXIf a memory operand uses a segment containing a NULL selector.
XIf a memory operand (using a segment other than SS) is in non-canonical form.
#PF(fc) XXXIf a page fault occurs.
#AC(0) XXXIf alignment checking is enabled while the current privilege level is 3 and an unaligned memory access is made.