a number use in asm ,that time it is a sign number,and what time it is a unsign number.
there are only a few mathematical instructions, which differ between signed and unsigned:
idiv vs. div
imul vs. mul
jg vs. ja
jl vs. jb
(first is signed, second unsigned)
maybe some more, but I mainly need to think about, if I use this ones.
idiv vs. div
imul vs. mul
jg vs. ja
jl vs. jb
(first is signed, second unsigned)
maybe some more, but I mainly need to think about, if I use this ones.
As asm is not type checked at run time, a number is signed when you treat at as such (typically the high bit being set means it is negative, therefore signed). If you take a number, you can do a signed or an unsigned operation on it, but the result may be different between the two operations because one treats the data as signed. Also your signed and unsigned operations will affect the flags differently (as beaster mentioned).
The sign bit actually only affects some opcodes. For some opcodes it is possible that the result is the same for both the signed version and the unsigned version, but this does not applies to all the opcodes. (That's why there is shl, sal but shr is the same as sar).
So in fact the cpu does not need to know when the number is unsigned or not, it is the opcodes that determine whether the number is signed or unsigned.
So in fact the cpu does not need to know when the number is unsigned or not, it is the opcodes that determine whether the number is signed or unsigned.