Search code examples
adc

How to use ADC and set flag in Assembly


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.


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.