Consider multiplying two signed variables with the value -1
using imulq
.
The manual states: "The CF and OF flags are set when the signed integer value of the intermediate product differs from the sign extended operand-size-truncated product, otherwise the CF and OF flags are cleared."
Now, the binary 2's complement representation of -1
is the all-ones string, so (-1)*(-1) would yield a string that looks like (1...10 0...01), so the sign exension of the truncated result differs from the full one.
Does that mean that the OF flag will be set? This is really confusing, becuase intuitively there's no real overflow here.