Loop structures: Difference between revisions
Content added Content deleted
(Loop Structures in FeeBASIC) |
No edit summary |
||
Line 27: | Line 27: | ||
The below code snippet represents a loop that continues until a value greater than 3500 is read. However, it will also end after the 2000th iteration automatically, regardless of whether the condition is ever met. |
The below code snippet represents a loop that continues until a value greater than 3500 is read. However, it will also end after the 2000th iteration automatically, regardless of whether the condition is ever met. |
||
<syntaxhighlight lang="68000devpac"> |
|||
MOVE.W #1999,D1 ;DBxx loop counters need to be pre-decremented to work properly, since they terminate at $FFFF rather than 0 |
|||
LOOP: |
LOOP: |
||
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 |
||
</syntaxhighlight> |
|||
=={{header|AmbientTalk}}== |
=={{header|AmbientTalk}}== |