The ADC instruction
Addition with carry.
The ADC instruction format
| Instruction | Description |
|---|---|
| ADC AL, imm8 | Add imm8 to AL with carry. |
| ADC AX, imm16 | Add imm16 to AX with carry. |
| ADC reg/mem8, imm8 | Add imm8 to reg/mem8 with carry. |
| ADC reg/mem16, imm16 | Add imm16 to reg/mem16 with carry. |
| ADC reg/mem16, imm8 | Add sign-extended imm8 to reg/mem16 with carry. |
| ADC reg/mem8, reg8 | Add a byte register to reg/mem8 with carry. |
| ADC reg/mem16, reg16 | Add reg16 to reg/mem16 with carry. |
| ADC reg8, reg/mem8 | Add reg/mem8 to a byte register with carry. |
| ADC reg16, reg/mem16 | Add reg/mem16 to reg16 with carry. |
Adds the destination operand (first operand), the source operand (second operand) and the carry flag CF, and stores the result in the destination operand. The destination operand can be a register or a memory location; the source operand can be an immediate value, a register or a memory location. (Two memory operands, however, cannot be used in the same instruction.) The state of the CF flag represents a carry from a previous addition. When an immediate value is used as an operand, it is sign-extended to the length of the destination operand format.
The adc instruction is normally executed as part of a multi-byte or multi-word addition in which the add instruction is followed by the adc instruction.
Usage example
In this example we add the 16-bit number 0xFFFF (65535) to the 16-bit number 0x0003 (3). The result (65538) does not fit into a 16-bit register, so we use the register pair CX:AX, where CX holds the high part of the result.
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov ax, 0FFFFh ; Copy the value 1111 1111 1111 1111 into the ax register mov bx, 3 ; Copy the value 0000 0000 0000 0011 into the bx register xor cx, cx ; Clear the cx register, which will hold the high part of the result add ax, bx ; Add bx to ax adc cx, 0 ; Add 0 to the cx register with carry mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".