什么时候使用溢出标志?

问题描述

我认为我已经开始学习有关何时设置溢出标志的用例:当有符号位在有符号算术上改变时。例如,以下三种情况:

    # For example,with overflow:
    mov $0b00100000,%al # 32
    add $0b01100000,%al # 96
    # ---------------------
    #   $0b10000000  # Notice how the signed bit is set so the answer is -128,not +128

    # And with negative numbers (subtracting two negative numbers) where the sign =-bit is different
    # mov $-0b00100000,%al # 
    mov  $0b10000000,%al # -128
    add  $0b10000001,%al # -127
    # ---------------------
    #    $0b00000001  # +1 -- again the sign bit changes,so we have the overflow on

    # Doing the same thing but subtracting a positive number to get the overflow instead
    mov  $0b10000000,%al # -128
    sub  $0b00000100,%al # 4
    # ---------------------
    #    $0b01111100 # + 124 -- result is positive,so again we have overflow

但是,使用overflow标志时有哪些应用程序或用例?据我掌握的最低限度的Asm知识,似乎一直使用Z ero和S ign标志进行比较,但是在什么用例中使用O verflow标志? >

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)