Loop structures: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) No edit summary |
Puppydrum64 (talk | contribs) |
||
Line 22: | Line 22: | ||
=={{header|68000 Assembly}}== |
=={{header|68000 Assembly}}== |
||
'''NOT COVERED IN LOOP PAGES''' |
'''NOT COVERED IN LOOP PAGES''' |
||
The 68000 uses <code>DBxx Dn, label</code> for loop counting. "Dn" refers to a chosen data register. The "xx" is replaced with the condition code of your choice (<code>DBRA</code> stands for Decrement, Branch Always which is most commonly used). Execution will jump to the labeled line of code unless Dn's lower two bytes equal #$FFFF or the specified condition code is true, whichever occurs first. Keep in mind that the condition code has nothing to do with the value stored in Dn; rather, it represents the outcome of the operation just before the branch. This is similar to a "repeat until" construct in some other languages. |
The 68000 uses <code>DBxx Dn, label</code> for loop counting. "Dn" refers to a chosen data register. The "xx" is replaced with the condition code of your choice (<code>DBRA</code> stands for Decrement, Branch Always which is most commonly used). Execution will jump to the labeled line of code unless Dn's lower two bytes equal #$FFFF or the specified condition code is true, whichever occurs first. Keep in mind that the condition code has nothing to do with the value stored in Dn; rather, it represents the outcome of the operation just before the branch. This is similar to a "repeat until" construct in some other languages. |
||
Line 30: | Line 31: | ||
MOVE.W (A0)+,D0 |
MOVE.W (A0)+,D0 |
||
CMP.W #3501,D0 ;COMPARE TO #3501 |
CMP.W #3501,D0 ;COMPARE TO #3501 |
||
DBCC D1,LOOP ;DECREMENT, BRANCH UNTIL CARRY CLEAR OR D1 = #$FFFF |
DBCC D1,LOOP ;DECREMENT, BRANCH UNTIL CARRY CLEAR OR D1 = #$FFFF</lang> |
||
=={{header|AmbientTalk}}== |
=={{header|AmbientTalk}}== |