0

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

    # 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 知识中,似乎一直使用Zero 和Sign 标志进行比较,但是在哪些用例中使用了Overflow 标志?

4

0 回答 0