Microprocessor Simulator 0 Help



Download 1.18 Mb.
Page74/82
Date18.03.2021
Size1.18 Mb.
#56105
1   ...   70   71   72   73   74   75   76   77   ...   82
sms32v50 (3)
sms32v50 (3), sms32v50 (6)

Two's complement


The numbers work as follows.

The leftmost bit in an eight bit byte is the sign bit.


1 0 1 0 1 0 1 0

^

^ The sign bit has a value of -128 decimal or -80 hexadecimal.



The other seven bits are treated as a normal positive number between 0 and 127. This is true whether the overall number is positive or negative. For example to store -1 the binary is
1 1 1 1 1 1 1 1 - 128d + 127d = -1d

^

^ -128d



To store 127 decimal, the binary is
0 1 1 1 1 1 1 1 0 + 127d = 127d

^

^ The sign bit is zero.



16 and 32 bit machines also use the leftmost bit as the sign bit. The negative numbers work in exactly the same way but much bigger niumbers can be stored. In a 16 bit machine, the sign bit is worth -32768. In a 32 bit machine, the sign bit is worth -2147483648 (2000 million approximately).



Download 1.18 Mb.

Share with your friends:
1   ...   70   71   72   73   74   75   76   77   ...   82




The database is protected by copyright ©ininet.org 2024
send message

    Main page