ADC: Add With Carry

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeDescription
14 ib
ADC AL, imm8
AIValidValidValidAdd with carry imm8 to AL.
15 iw
ADC AX, imm16
AIValidValidValidAdd with carry imm16 to AX.
15 id
ADC EAX, imm32
AIValidValidValidAdd with carry imm32 to EAX.
REX.W 15 id
ADC RAX, imm32
AINot EncodableNot EncodableValidAdd with carry imm32 (sign extended to 64 bits) to RAX
80 /2 ib
ADC r/m8, imm8
MIValidValidValidAdd with carry imm8 to r/m8.
REX 80 /2 ib
ADC r/m8*, imm8
MINot EncodableNot EncodableValidAdd with carry imm8 to r/m8.
81 /2 iw
ADC r/m16, imm16
MIValidValidValidAdd with carry imm16 to r/m16.
81 /2 id
ADC r/m32, imm32
MIValidValidValidAdd with carry imm32 to r/m32.
REX.W 81 /2 id
ADC r/m64, imm32
MINot EncodableNot EncodableValidAdd with carry imm32 (sign extended to 64 bits) too r/m64.
82 /2 ib
ADC r/m8, r8
MIValidValidInvalidUndocumented alias for 80 /2 ib. Add with carry r8 (sign extended to 8 bits) to r/m8.
83 /2 ib
ADC r/m16, imm8
MIValidValidValidAdd with carry imm8 (sign extended to 16 bits) to r/m16.
83 /2 ib
ADC r/m32, imm8
MIValidValidValidAdd with carry imm8 (sign extended to 32 bits) to r/m32.
REX.W 83 /2 ib
ADC r/m64, imm8
MINot EncodableNot EncodableValidAdd with carry imm8 (sign extended to 64 bits) to r/m64.
10 /r
ADC r/m8, r8
MRValidValidValidAdd with carry r8 to r/m8.
REX 10 /r
ADC r/m8*, r8*
MRNot EncodableNot EncodableValidAdd with carry r8 to r/m8.
11 /r
ADC r/m16, r16
MRValidValidValidAdd with carry r16 to r/m16.
11 /r
ADC r/m32, r32
MRValidValidValidAdd with carry r32 to r/m32.
REX.W 11 /r
ADC r/m64, r64
MRNot EncodableNot EncodableValidAdd with carry r64 to r/m64.
12 /r
ADC r8, r/m8
RMValidValidValidAdd with carry r/m8 to r8.
REX 12 /r
ADC r8*, r/m8*
RMNot EncodableNot EncodableValidAdd with carry r/m8 to r8.
13 /r
ADC r16, r/m16
RMValidValidValidAdd with carry r/m16 to r16.
13 /r
ADC r32, r/m32
RMValidValidValidAdd with carry r/m32 to r32.
REX.W 13 /r
ADC r64, r/m64
RMNot EncodableNot EncodableValidAdd with carry r/m64 to r64.

Encoding

EncodingOperand 1Operand 2
AIAL/AX/EAX/RAX[rw]imm8/16/32[r]
MIModRM.r/m[rw]imm8/16/32[r]
MRModRM.r/m[rw]ModRM.reg[r]
RMModRM.reg[rw]ModRM.r/m[r]

Description

The ADC 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. It does not differentiate between signed and unsigned operands, but will set the OF and CF to indicate a carry for signed and unsigned results (respectively).

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

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.
// `src` is sign extended to the width of `dest`
public void ADC_8(ref byte dest, byte src) {
  CF:dest = dest + src + CF;
}
public void ADC_16(ref ushort dest, ushort src) {
  CF:dest = dest + src + CF;
}
public void ADC_32(ref uint dest, uint src) {
  CF:dest = dest + src + CF;
}
public void ADC_64(ref ulong dest, ulong src) {
  CF:dest = 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.

C Intrinsics

Exceptions

Protected Mode

#GP(0)
If the destination is located in a non-writable segment.
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register is used to access memory and it contains a NULL segment selector.
#SS(0)
If a memory operand effective address is outside the SS segment limit.
#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.
#UD
If the LOCK prefix is used but the destination is not a memory operand.

Real-Address Mode

#GP
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#SS
If a memory operand effective address is outside the SS segment limit.
#UD
If the LOCK prefix is used but the destination is not a memory operand.

Virtual-8086 Mode

#GP(0)
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#SS(0)
If a memory operand effective address is outside the SS segment limit.
#PF(fault-code)
If a page fault occurs.
#AC(0)
If alignment checking is enabled and an unaligned memory reference is made.
#UD
If the LOCK prefix is used but the destination is not a memory operand.

Compatibility Mode

Same exceptions as in protected mode.

Long Mode

#SS(0)
If a memory address referencing the SS segment is in a non-canonical form.
#GP(0)
If a memory operand 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.
#UD
If the LOCK prefix is used but the destination is not a memory operand.