SPRU513Z August 2001 – October 2023 SM320F28335-EP
Assemble Code Block Repeatedly
.loop [count]
.break [end-condition]
.endloop
Three directives allow you to repeatedly assemble a block of code:
The .loop directive begins a repeatable block of code. The optional count operand, if used, must be a well-defined integer expression. The count indicates the number of loops to be performed (the loop count). If count is omitted, it defaults to 1024. The loop will be repeated count number of times, unless terminated early by a .break directive.
The optional .break directive terminates a .loop early. You may use .loop without using .break. The .break directive terminates a .loop only if the end-condition expression is true (evaluates to nonzero). If the optional end-condition operand is omitted, it defaults to true. If end-condition is true, the assembler stops repeating the .loop body immediately; any remaining statements after .break and before .endloop are not assembled. The assembler resumes assembling with the statement after the .endloop directive. If end-condition is false (evaluates to 0), the loop continues.
The .endloop directive marks the end of a repeatable block of code. When the loop terminates, whether by a .break directive with a true end-condition or by performing the loop count number of iterations, the assembler stops repeating the loop body and resumes assembling with the statement after the .endloop directive.
This example illustrates how these directives can be used with the .eval directive. The code in the first six lines expands to the code immediately following those six lines.
1 .eval 0,x
2 COEF .loop
3 .word x*100
4 .eval x+1, x
5 .break x = 6
6 .endloop
1 000000 0000 .word 0*100
1 .eval 0+1, x
1 .break 1 = 6
1 000001 0064 .word 1*100
1 .eval 1+1, x
1 .break 2 = 6
1 000002 00C8 .word 2*100
1 .eval 2+1, x
1 .break 3 = 6
1 000003 012C .word 3*100
1 .eval 3+1, x
1 .break 4 = 6
1 000004 0190 .word 4*100
1 .eval 4+1, x
1 .break 5 = 6
1 000005 01F4 .word 5*100
1 .eval 5+1, x
1 .break 6 = 6