Arithmetic Overflow vs. Arithmetic Carry

后端 未结 2 1799
陌清茗
陌清茗 2021-02-01 04:14

One of my lecture slides gives an example of arithmetic overflow and carry in a topic for conditional branching flags on an ARM chip, quoted below:

  • V (overflow) - 
相关标签:
2条回答
  • 2021-02-01 04:38
    • Overflow flags get set when the register cannot properly represent the result as a signed value (you overflowed into the sign bit).
    • Carry flags are set when the register cannot properly represent the result as an unsigned value (no sign bit required).
    0 讨论(0)
  • 2021-02-01 04:43

    You get an overflow, if the sign bit is corrupted. So you know that you have to adjust your result.

    You get a carry if the result does not fit in this value. (need more bits than you have).

    In the old days you had to write your own addition and multiplication subroutines for multi byte values.

    0 讨论(0)
提交回复
热议问题