Crossware

Table of Contents        Previous topic       Next topic       

CROSS ASSEMBLER->Structured Assembly->WHILE/DO/ENDW

The WHILE/DO/ENDW construct will generate a loop testing for repetition at the beginning of the loop.

     WHILE.<size> <expression> DO.<distance>
     <your assembly code>
     ENDW

<size> can be .B, .W or .L and the assembler will use this size when it generates the compare instructions.  If no size is specified, the assembler will assume .W.  However if either of the operands of a pair is an address register, the size of the compare will always be .L.

<distance> can be .S, .W and for chips that support long branches .L.  The assembler will use this when it generates code for forward branches.

See IF/THEN/ELSE/ENDI for the syntax of <expression>.

Example 1:

    WHILE.L <CC> DO.S
    <your assembly code>
    ENDW

will generate the following assembler code:

.00000
         BCS.S     .00001
         <your assembly code>
         BRA       .00000
.00001

Example 2:

    WHILE.L D1 <EQ> D2 DO.S
    <your assembly code>
    ENDW

will generate the following assembler code:

.00002
         CMP.L     D2,D1
         BNE.S     .00003
         <your assembly code>
         BRA       .00002
.00003

Example 3:

    WHILE.L D1 <EQ> (A1) AND D1 <NE> #35 DO.S
    <your assembly code>
    ENDW

will generate the following assembler code:

.00004
         CMP.L     (A1),D1
         BNE.S     .00005
         CMP.L     #35,D1
         BEQ.S     .00005
         <your assembly code>
         BRA       .00004
.00005