2 yzy4829229 yzy4829229 于 2015.06.15 08:58 提问

关于8086CPU标志寄存器溢出的问题

文章说,对于溢出只是针对于有符号数,但是对于无符号数,比如8为寄存器,表示的
范围是0~255,如果两个正数相加超过了255,不叫溢出了吗?为什么这里只讨论的是有
符号的数

1个回答

nswcfd
nswcfd   2015.06.15 12:08

手头没有8086的文档,模糊记得eflags里面有CF和OF两个标记,你说的“溢出”应该对应CF,即产生了进位。OF对于有符号数。

The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the results of arithmetic instructions,
such as the ADD, SUB, MUL, and DIV instructions. The status flag functions are:
CF (bit 0) Carry flag — Set if an arithmetic operation generates a carry or a borrow out of the mostsignificant
bit of the result; cleared otherwise. This flag indicates an overflow condition for
unsigned-integer arithmetic.
OF (bit 11) Overflow flag — Set if the integer result is too large a positive number or too small a negative
number (excluding the sign-bit) to fit in the destination operand; cleared otherwise. This
flag indicates an overflow condition for signed-integer (two’s complement) arithmetic.

yzy4829229
yzy4829229 无符号数超出范围,OF不管呢
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片