Difference between revisions of "680x0:Condition codes"
Spellcoder (talk | contribs) (New page: Condition codes are used in branch instructions Bcc and DBcc.<br /> Replace the cc with any of the following codes: <table class="sortable"> <tr><th>cc</th><th>meaning</th><th>bitcode</t...) |
Spellcoder (talk | contribs) (added explaination/example) |
||
(2 intermediate revisions 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>meaning</th><th>bitcode</th></tr> | + | <tr><th>cc</th><th>mathematical</th><th>meaning</th><th>bitcode</th><th>signed</th><th>comment</th></tr> |
− | <tr><td> | + | <tr><td>NE</td><td>b<>a</td><td>Not equal</td><td>0110</td><td></td></tr> |
− | <tr><td> | + | <tr><td>EQ</td><td>b==a</td><td>Equal</td><td>0111</td><td></td></tr> |
− | <tr><td> | + | |
− | <tr><td> | + | <tr><td>HI</td><td>b>a</td><td>HIgher</td><td>0010</td><td>unsigned</td></tr> |
− | <tr><td> | + | <tr><td>LO</td><td>b<a</td><td>LOwer</td><td></td><td>unsigned</td></tr> |
− | <tr><td> | + | <tr><td>HS</td><td>b>=a</td><td>Higher or Same</td><td></td><td>unsigned</td></tr> |
− | <tr><td> | + | <tr><td>LS</td><td>b<=a</td><td>Lower or same</td><td>0011</td><td>unsigned</td></tr> |
− | <tr><td> | + | |
− | <tr><td> | + | <tr><td>GT</td><td>b>a</td><td>Greater Then</td><td>1110</td><td>signed</td></tr> |
− | <tr><td> | + | <tr><td>LT</td><td>b<a</td><td>Less Then</td><td>1101</td><td>signed</td></tr> |
− | <tr><td>MI</td><td>Minus</td><td>1011</td></tr> | + | <tr><td>GE</td><td>b>=a</td><td>Greater then or Equal</td><td>1100</td><td>signed</td></tr> |
− | <tr><td> | + | <tr><td>LE</td><td>b<=a</td><td>Less then or Equal</td><td>1111</td><td>signed</td></tr> |
− | <tr><td> | + | |
− | <tr><td> | + | <tr><td>MI</td><td>b<0</td><td>Minus</td><td>1011</td><td></td></tr> |
− | <tr><td>VC</td><td>No overflow</td><td>1000</td></tr> | + | <tr><td>PL</td><td>b>0</td><td>Plus</td><td>1010</td><td></td></tr> |
− | <tr><td>VS</td><td>Overflow</td><td>1001</td></tr> | + | |
+ | <tr><td>CC</td><td></td><td>Carry clear</td><td>0100</td><td></td></tr> | ||
+ | <tr><td>CS</td><td></td><td>Carry set</td><td>0101</td><td></td></tr> | ||
+ | |||
+ | <tr><td>VC</td><td></td><td>No overflow</td><td>1000</td><td></td></tr> | ||
+ | <tr><td>VS</td><td></td><td>Overflow</td><td>1001</td><td></td></tr> | ||
+ | |||
+ | <tr><td colspan=6><br />(the next 2 are not known by all assemblers, because they aren't really usefull) | ||
+ | (Seka does know them)</td></tr> | ||
+ | <tr><td>T</td><td></td><td>True</td><td>0000</td><td></td><td>allways branch, same as bra</td></tr> | ||
+ | <tr><td>F</td><td></td><td>False</td><td>0001</td><td></td><td>never branch</td></tr> | ||
+ | |||
</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. |
|