Difference between revisions of "680x0:Condition codes"
Spellcoder (talk | contribs) (added signed/unsigned, mathematical meaning and some more CC's) |
Spellcoder (talk | contribs) (added explaination/example) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | {| | ||
+ | |valign=top| | ||
Condition codes are used in branch instructions Bcc and DBcc.<br /> | Condition codes are used in branch instructions Bcc and DBcc.<br /> | ||
− | Replace the cc with any of the | + | Replace the cc with any of the code you see in the list. |
+ | ===Example=== | ||
+ | If you like to branch/goto another place in the code if a signed number is greater or equal to 8 use: | ||
+ | |||
+ | <code><pre> | ||
+ | CMP.B #8,D0 | ||
+ | BGE ItsGreaterOrEqual | ||
+ | |||
+ | ItsGreaterOrEqual: | ||
+ | </pre></code> | ||
+ | |||
+ | |||
+ | ===Signed/unsigned=== | ||
+ | Unsigned numbers can only be positive, while in signed numbers the highest bit is used to tell if the number is negative. As assembler programmer it's up to you to conciously choose the correct condition code for signed/unsigned numbers. | ||
+ | |width=60| | ||
+ | |valign=top| | ||
<table class="sortable"> | <table class="sortable"> | ||
<tr><th>cc</th><th>mathematical</th><th>meaning</th><th>bitcode</th><th>signed</th><th>comment</th></tr> | <tr><th>cc</th><th>mathematical</th><th>meaning</th><th>bitcode</th><th>signed</th><th>comment</th></tr> | ||
Line 8: | Line 25: | ||
<tr><td>EQ</td><td>b==a</td><td>Equal</td><td>0111</td><td></td></tr> | <tr><td>EQ</td><td>b==a</td><td>Equal</td><td>0111</td><td></td></tr> | ||
− | <tr><td>HI</td><td>b>a</td><td> | + | <tr><td>HI</td><td>b>a</td><td>HIgher</td><td>0010</td><td>unsigned</td></tr> |
<tr><td>LO</td><td>b<a</td><td>LOwer</td><td></td><td>unsigned</td></tr> | <tr><td>LO</td><td>b<a</td><td>LOwer</td><td></td><td>unsigned</td></tr> | ||
<tr><td>HS</td><td>b>=a</td><td>Higher or Same</td><td></td><td>unsigned</td></tr> | <tr><td>HS</td><td>b>=a</td><td>Higher or Same</td><td></td><td>unsigned</td></tr> | ||
<tr><td>LS</td><td>b<=a</td><td>Lower or same</td><td>0011</td><td>unsigned</td></tr> | <tr><td>LS</td><td>b<=a</td><td>Lower or same</td><td>0011</td><td>unsigned</td></tr> | ||
− | <tr><td>GT</td><td>b>a</td><td>Greater | + | <tr><td>GT</td><td>b>a</td><td>Greater Then</td><td>1110</td><td>signed</td></tr> |
− | <tr><td>LT</td><td>b<a</td><td>Less | + | <tr><td>LT</td><td>b<a</td><td>Less Then</td><td>1101</td><td>signed</td></tr> |
− | <tr><td>GE</td><td>b>=a</td><td>Greater then or | + | <tr><td>GE</td><td>b>=a</td><td>Greater then or Equal</td><td>1100</td><td>signed</td></tr> |
− | <tr><td>LE</td><td>b<=a</td><td>Less then or | + | <tr><td>LE</td><td>b<=a</td><td>Less then or Equal</td><td>1111</td><td>signed</td></tr> |
<tr><td>MI</td><td>b<0</td><td>Minus</td><td>1011</td><td></td></tr> | <tr><td>MI</td><td>b<0</td><td>Minus</td><td>1011</td><td></td></tr> | ||
Line 33: | Line 50: | ||
</table> | </table> | ||
+ | |} |
Latest revision as of 23:45, 4 March 2008
Condition codes are used in branch instructions Bcc and DBcc.
ExampleIf you like to branch/goto another place in the code if a signed number is greater or equal to 8 use:
Signed/unsignedUnsigned numbers can only be positive, while in signed numbers the highest bit is used to tell if the number is negative. As assembler programmer it's up to you to conciously choose the correct condition code for signed/unsigned numbers. |
|