哪些指令会改变汇编的标志位(再附个总结)

   这些书上都没有现成的答案,需要自己总结,感谢BEYOND0769,做出这么出色的总结。以下是会改变标志位的指令。
(1)
加法指令:ADD、ADC、INC、XADD除了INC不影响CF标志位外,都影响条件标志位。
                  CF、ZF、SF、OF
                  CF最高位是否有进位
                  DF若两个操作数符号相同而结果符号与之相反OF=1,否则OF=0.

减法指令:SUB、SBB、DEC、NEG、CMP、CMPXCHG、CMPXCHG8B
                  前六种除了DEC不影响CF标志外都影响标志位。CMPXHG8B只影响ZF。
                  CF说明无符号数相减的溢出,同时又确实是被减数最高有效位向高位的借位。
                  OF位则说明带符号数的溢出
                  无符号运算时,若减数>被减数,有借位CF=1,否则CF=0.
                  OF若两个数符号相反,而结果的符号与减数相同则OF=1.否则OF=0.

乘法指令:MUL、IMUL
                  MUL:如果乘积高一半为0,则CF和OF位均为0,否则CF和OF均为1.
                  IMUL:如果高一半是低一半符号的扩展,则CF位和OF位均为0,否则就均为1.

除法指令:DIV、IDIV   对所有条件位均无定义。

逻辑指令:AND、OR、NOT、XOR、TEST
                   NOT不允许使用立即数,其它4条指令除非源操作数是立即数,至少要有一个操作数必须存放在寄存器中。另一个操作数则可以使用任意寻址方式。
                   NOT不影响标志位,其余4种CF、OF、置0,AF无定义,SF、ZF、PF位看情况而定。

定位扫描指令:BSF正向位扫描、BSR反向位扫描
                          源操作数可以是除立即数以外的任一种寻址方式,目的操作数必须是寄存器,影响ZF位。

以上转自:http://zhidao.baidu.com/question/130863024.html
(2)再附上个跳转条件的总结:
Topic:     Jump   Conditions  


    Opcode             Mnemonic     Flags   Checked         Description
----------------------------------------------------------------------------

    size   0010       JB/JNAE       CF=1                           Jump   if   below/not   above   or
                                                                                  equal   (unsigned   comparisons)
    size   0011       JAE/JNB       CF=0                           Jump   if   above   or   equal/not
                                                                                  below   (unsigned   comparisons)
    size   0110       JBE/JNA       CF=1   or   ZF=1           Jump   if   below   or   equal/not
                                                                                  above   (unsigned   comparisons)
    size   0111       JA/JNBE       CF=0   and   ZF=0         Jump   if   above/not   below   or
                                                                                  equal   (unsigned   comparisons)
    size   0100       JE/JZ           ZF=1                           Jump   if   equal   (zero)
    size   0101       JNE/JNZ       ZF=0                           Jump   if   not   equal   (not   zero)
    size   1100       JL/JNGE       SF <> OF                       Jump   if   less/not   greater   or
                                                                                  equal   (signed   comparisons)
    size   1101       JGE/JNL       SF=OF                         Jump   if   greater   or   equal/not
                                                                                  less   (signed   comparisons)
    size   1110       JLE/JNG       ZF=1   or   SF <> OF       Jump   if   less   or   equal/not
                                                                                  greater   (signed   comparisons)
    size   1111       JG/JNLE       ZF=0   and   SF=OF       Jump   if   greater/not   less   or
                                                                                  equal   (signed   comparisons)
    size   1000       JS                 SF=1                           Jump   if   sign
    size   1001       JNS               SF=0                           Jump   if   not   sign
    size   0010       JC                 CF=1                           Jump   if   carry
    size   0011       JNC               CF=0                           Jump   if   not   carry
    size   0000       JO                 OF=1                           Jump   if   overflow
    size   0001       JNO               OF=0                           Jump   if   not   overflow
    size   1010       JP/JPE         PF=1                           Jump   if   parity/parity   even
    size   1011       JNP/JPO       PF=0                           Jump   if   no   parity/parity   odd
----------------------------------------------------------------------------

    NOTE:   The   size   bits   are   0111   for   short   jumps   or   1000   for   80386/486
                near   jumps.

猜你喜欢

转载自nannan408.iteye.com/blog/970585
今日推荐