CS 3843 Computer Organization
Notes on Chapter 3: Flags
- For cmp S2, S1
negative refers to S1 - S2
greater, less, above, or below refer to comparing S1 to S2
- The CF flag is used for unsigned overlow.
- cmp S2, S1 sets the CF flag if
S1 - S2 is (mathematically) negative or
S1 is below S2.
- The OF flag is used for signed overlow.
- The OF flag is set when
sub S2, S1 gives the wrong answer.
- When sub S2, S1 gives the wrong answer,
the SF is incorrect.
- S1 - S2 is (mathematically) negative is the same
as S1 is less than S2.
- If the OF is not set, the SF tells you if
S1 is less than S2.
- If the OF is set, the SF gives you the wrong result about
S1 is less than S2.
- The correct result about
S1 is less than S2 is given by SF^OF.