汇编问题关于CF寄存器和OF寄存器

汇编问题关于CF寄存器和OF寄存器
书上看到的一句话:The CPU uses an interesting mechanism to determine
the state of the Overflow flag after an addition or subtraction operation. The Carry flag is exclusive ORed with the high bit of the result. The resulting value is placed in the Overflow flag.
就是说汇编里的OF寄存器里的值是CF和运算结果的最高位异或的结果.
书上的例子:
两个 8位 二进制数 10000000 and 11111110 相加
CF = 1MSB = 0, 1 XOR 0 所以OF = 1.
1 0 0 0 0 0 0 0
+ 1 1 1 1 1 1 1 0
CF10 1 1 1 1 1 1 0
结果和书上所说的一致.

但是如果对于8位 二进制数1111 1111和0000 0001

0 0 0 00 0 0 1
+ 1 1 1 11 1 1 1
CF 1 0 0 0 00 0 0 0

CF = 1MSB = 0,1 XOR 0 所以OF = 1,但是如果这两个数是有符号数,分别为1和-1,它们相加OF必定为0!

那这句话有什么问题吗?还是我的例子有问题?
数学人气:981 ℃时间:2020-06-14 21:22:03
优质解答
CF,是运算结果的《最高位》的进位.
运算结果的《次高位》,还有一个进位.
OF寄存器里的值,是CF和《次高位的进位》异或的结果.
即,相邻的两个进位,异或之后,就成了 OF.所以书上这句话是错的吧?OF寄存器里的值是《CF和运算结果的最高位异或的结果。》这句,不对。最后一个问题:The Carry flag is exclusive ORed with the high bit of the result.The resulting value is placed in the Overflow flag.这句呢?是我的理解错了吗?这是书上的原话。 ~谢谢with the high bit of the result--这句,是说《结果的高位》。但是,它说的,不对。应该是:OF寄存器里的值,是CF和《次高位的进位》异或的结果。
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版