Structured Control - DBloop
DBloop - Implements a loop using the decrement and branch conditional instruction (DBcc). After each pass through the loop the data register Dn is decremented by 1. The loop continues until Dn = -1 or until an optional <expression> is true.
The DBloop statement has the following syntax:
DBLOOP Dn = op1
code
UNLESS[.size] [expression]
size - The value B, W, or L, specifying the size
of the operand comparison. These values correspond to the Byte, Word, or
Long word data size.
A size may not be specified when the expression consists of only a condition
code.
expression - The expression tested. For a description of the expression syntax, see the Expression Syntax page. If the expression field is empty or contains <F> the assembler will output a DBRA instruction resulting in a loop that loops op1 + 1 times.
code - The series of assembly commands executed until the expression is true or Dn is decremented to -1.
op1 - The initial number to be stored in data register Dn. May be any addressing mode.
One space should be used to separate each part of the statement.
===Notes===
The code instructions are executed once even if the expression is true upon entry. Compound expressions are not supported.
The CCR's (condition code register) flags are modified by this command after each execution of the code instructions.
EXAMPLE
DBLOOP D0 = #5
loops 6 times
code
UNLESS.W (A0) <LT> #$200 exit loop if (A0) <
$200
DBLOOP D0 = #4
loops 5 times
code
UNLESS