I've encountered two possibilities for how the carry flag can be set with:
0x00_00_00_00_00_00_00_00 - 0x80_00_00_00_00_00_00_00
(underscores to show bytes)
If I did this by subtraction, we would have to borrow from a bit we don't have, which should set the CF
to 1
.
However, I was under the impression that ALUs do not subtract, but rather just add the two's complement. The two's complement of 0x80_00_00_00_00_00_00_00
is 0x80_00_00_00_00_00_00_00
. So,
0x00_00_00_00_00_00_00_00 - 0x80_00_00_00_00_00_00_00
does not carry any bits out of the 63 bit, which would set the CF
to 0
.
Which of these situations is valid for 64 bit values in x86?
Does the ALU actually carry out a subtraction or does it convert to 2's complement and the converted values to do a subtraction?