I am reading the book Art of Assembly Language. There I came across this paragraph.
If the H.O. bit is zero, then the number is positive and is stored as a standard binary value. If the H.O. bit is one, then the number is negative and is stored in the two’s comple-ment form. To convert a positive number to its negative, two’s complement form, you use the following algorithm:
Invert all the bits in the number, i.e., apply the logical
NOTfunction.Add one to the inverted result.
For example, to compute the eight bit equivalent of
-5:0000 0101 Five (in binary) 1111 1010 Invert all the bits. 1111 1011 Add one to obtain result.
Here I want to know if 0000 0101 is 5 in decimals and 1111 1011 is -5 then how we represent 251? Is not the same 1111 1011? How the computer distinguishes between -5 and 251?
01will mean1if interpreted as signed or unsigned. However, the value11would be interpreted as 3 if it's considered unsigned, or as -1 if we consider it signed. - ruslik