Different CPUs have different things, including flags.
But for a MIP, we have 4:
- Overflow
- Result is zero
- Result is negative
Overflow
- For unsigned numbers, if , then there is overflow
- For signed numbers (either A or B are negative):
- For G = A + B, we have overflow when
- A and B have the same sign
- G has opposite sign
- For G = A - B, we have overflow when
- A and B have different signs
- G has the same sign as B
- E.g: A = -2 and B = 15. A - B = -17. B is negative; -17 is negative. We have overflow!
- For G = A + B and A, B have different signs
- It can never overflow!
- For G = A + B, we have overflow when
Zero Flag (not on the slides)
=
- Checks if any number is 1. If it is, itβs not zero!