binary - 二进制补码; 0FFFFh 正,0FFFFh 负?

标签 binary x86 twos-complement

组装艺术一书中,我复制了这句话:

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,那么就是负数。

computer-programming-forum.com/46-asm/1b99282efbac3bcf.htm

关于binary - 二进制补码; 0FFFFh 正,0FFFFh 负?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15643332/

相关文章:

twos-complement - 为什么这两个的补码快捷方式有效?

c - 在 C 中将 int 写入二进制文件时出现问题

Java NumberFormatException?

c# - Visual Studio : How to properly build and specify the configurations and platforms for x64 and x86

assembly - 不带 hlt 的 HLT 指令

java - 如何将java中的十六进制值发送到RS232串口

string - 找到二进制字符串时删除文件中的字节

java - 二元运算符 "&"java 的错误操作数类型

c - 内联汇编 : operand type mismatch for `in'

type-conversion - to_unsigned 做什么?