0
我想知道关于NEG指令,它是否也会影响溢出标志!!!我知道这只是否定变量的值,但不能知道它是否会影响溢出标志在汇编语言中设置NEG指令设置溢出标志
我想知道关于NEG指令,它是否也会影响溢出标志!!!我知道这只是否定变量的值,但不能知道它是否会影响溢出标志在汇编语言中设置NEG指令设置溢出标志
如果您想知道指令的用途,请参阅参考手册。
的essential reference, namely the Intel instruction set manual说,这对NEG指令:
Flags Affected
The CF flag set to 0 if the source operand is 0; otherwise it is set to 1.
The OF, SF, ZF, AF, and PF flags are set according to the result.
所以很显然的是,NEG指令集的 O标志;因此影响 O标志,这是OP的原始问题。它每次执行都会这样做。 (人们不应将“没有改变”与“未改变”混为一谈)。
该特定参考手册未提供特定算法来指示何时将O设置为零或1。但是,英特尔CPU是2的补充机器。 Subtract指令具有完全相同的措词。 NEG X相当于(0 SUBTRACT X)。因此,NEG应根据“0 SUBTRACT X”的“溢出”设置O位;当X是0x8000000时,这将设置O.
检查的Intel Basic Archiecture Manual,我们发现的位的描述:
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
证实了我们的理解。
为什么不检查指令集引用而不是在这里询问并等待答案? – Jester 2014-10-18 13:52:33
我在那里看过,但它真的很难从那里得到...只需要一到两个线路的答案,我只是新来这.. – 2014-10-18 13:56:41