x86 Assembly: INC and DEC instruction and overflow flag

前端 未结 7 1473
庸人自扰
庸人自扰 2020-12-05 03:20

In x86 assembly, the overflow flag is set when an add or sub operation on a signed integer overflows, and the carry flag is set when an operation o

7条回答
  •  既然无缘
    2020-12-05 04:02

    As many of the other answers have pointed out, INC and DEC do not affect the CF, whereas ADD and SUB do.

    What has not been said yet, however, is that this might make a performance difference. Not that you'd usually be bothered by that unless you are trying to optimise the hell out of a routine, but essentially not setting the CF means that INC/DEC only write to part of the flags register, which can cause a partial flag register stall, see Intel 64 and IA-32 Architectures Optimization Reference Manual or Agner Fog's optimisation manuals.

提交回复
热议问题