1
votes

Since documentation doesn't really describe how the flags are affected, I couldn't figure out what's the difference between carry and signed flag during sub instruction, it seems like whenever a < b in sub a, b both carry and signed flags will be set. Is there a case where signed flag will be set without carry (or vice versa) during sub instruction ?

1
Yes, of course. sub 1, 2 will produce result -1 which is fine in signed (no overflow) but wraps around in unsigned (hence carry). - Jester
AFAIK, the Intel documentation does describe which flags are affected how. - Rudy Velthuis

1 Answers

3
votes

Is there a case where signed flag will be set without carry (or vice versa) during sub instruction ?

Sure:

mov al,0xFE
sub al,2

The result is 0xFC, which when viewed as signed 8-bit is -4. So the SF will be set, buf CF will be clear (carry can be viewed as "unsigned less than", and 0xFE is obviously not unsigned less than 2).