Question

I understand what ADC does but I'm not sure how to manage the carry flag. If I use a regular ADD and it overflows, will it automatically set the carry flag to be 1? And if I use ADC and the CF is 1 and it doesn't overflow, will it set the CF to be 0? Thanks.

Était-ce utile?

La solution

Assuming intel x86 assembler: Both ADD and ADC will set the Carry Flag on high-order bit carry or borrow and it will be cleared otherwise.

Using ADC when the CF is 1 and there is no overflow, will result in CF=0.

Autres conseils

For details, see the official reference at www.intel.com, page 498.

Description Adds the destination operand (first operand), the source operand (second operand), and the carry (CF) flag 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, a register, or a memory location. (However, two memory operands cannot be used in one 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. [...]

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top