从组装艺术一书中,我复制了这句话:
In the two’s complement system, the H.O. bit of a number is a sign bit. If the H.O. bit is zero, the number is positive; if the H.O. bit is one, the number is negative. Examples:
For 16-bit numbers:
8000h
is negative because the H.O. bit is one.
100h
is positive because the H.O. bit is zero.
7FFFh
is positive.
0FFFFh
is negative.
0FFFh
is positive.
我不明白最后两个例子。如果将这两个示例转换为二进制,第一个示例将得到 0000 1111 1111 1111 1111
,第二个示例将得到 0000 1111 1111 1111
。为什么前者是负数,后者是正数?在我看来,两者的最高位都是 0,因此两者都应该是正数。
最佳答案
The reason for the leading 0 on 0FFFFH is to give the assember/compiler a hint that F is part of a number. Not all assemblers require this.
所以负数实际上是FFFFh,所以1111 1111 1111 1111,那么就是负数。
关于binary - 二进制补码; 0FFFFh 正,0FFFFh 负?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15643332/