Home > Back-end >  Unsigned integer subtraction of the carry flag is set
Unsigned integer subtraction of the carry flag is set

Time:01-24

Recently in the "deep understanding of computer systems," say when a and b are unsigned integers, t=a - b in performing calculations, when a - b<0, CMP instructions will set the carry flag, but, for example, 4 to 7=0100 + 1001=1101 (regardless of the number of signed or unsigned number computer are converted to complement the addition subtraction), the highest at this time did not carry, why will set the carry flag? Or is the carry flag CMP instruction to judge the results after less than zero set forced?

CodePudding user response:

What time is the highest carry

CodePudding user response:

refer to the original poster ciel00000 response:
recently in the "deep understanding of computer systems," said inside when a and b are unsigned integers, t=a - b in performing calculations, when a - b<0, CMP instructions will set the carry flag, but, for example, 4 to 7=0100 + 1001=1101 (regardless of the number of signed or unsigned number computer are converted to complement the addition subtraction), the highest at this time did not carry, why will set the carry flag? Or is the carry flag CMP instruction to judge the results after less than zero set forced?


Look here
https://blog.csdn.net/lc_miao/article/details/84929497

CodePudding user response:

Computer principle already lost don't know where the
I remember the assembly has a sf, register, it according to the result of addition and subtraction highest setting, regardless of whether any symbolic operation

CodePudding user response:

Computer in the face of a signed and unsigned calculations are the same, just for the computed results in accordance with the signed and unsigned to explain output
Subtraction is the operand turned negative complement way in addition to perform after
Carry remember is specialized hardware mark, is the study of the principle of hardware design?

CodePudding user response:

CF in the concrete to determine not only according to the highest when the presence of carry, but the CF=(highest carry) ^ (addition/subtraction), which subtract when the latter for 1.
Also recently in the book, happen to also have this question,
  • Related