SPRUI03E June 2015 – January 2023
The conditional assembly directives are .if/.elseif/.else/.endif and .loop/ .break/.endloop. They can be nested within each other up to 32 levels deep. The format of a conditional block is:
.if well-defined expression | |
[.elseif well-defined expression] | |
[.else] | |
.endif |
The .elseif and .else directives are optional in conditional assembly. The .elseif directive can be used more than once within a conditional assembly code block. When .elseif and .else are omitted and when the .if expression is false (0), the assembler continues to the code following the .endif directive. See Assemble Conditional Blocks for more information on the .if/ .elseif/.else/.endif directives.
The .loop/.break/.endloop directives enable you to assemble a code block repeatedly. The format of a repeatable block is:
.loop [well-defined expression] | |
[.break [well-defined expression]] | |
.endloop |
The .loop directive's optional well-defined expression evaluates to the loop count (the number of loops to be performed). If the expression is omitted, the loop count defaults to 1024 unless the assembler encounters a .break directive with an expression that is true (nonzero). See Assemble Conditional Blocks Repeatedly for more information on the .loop/.break/.endloop directives.
The .break directive and its expression are optional in repetitive assembly. If the expression evaluates to false, the loop continues. The assembler breaks the loop when the .break expression evaluates to true or when the .break expression is omitted. When the loop is broken, the assembler continues with the code after the .endloop directive. For more information, see Section 6.8.
The .loop/.break/.endloop Directives, Nested Conditional Assembly Directives, and Built-In Substitution Symbol Functions in a Conditional Assembly Code Block show the .loop/.break/ .endloop directives, properly nested conditional assembly directives, and built-in substitution symbol functions used in a conditional assembly code block.
.asg 1,x
.loop
.break (x == 10) ; if x == 10, quit loop/break with expression
.eval x+1,x
.endloop
.asg 1,x
.loop
.if (x == 10) ; if x == 10, quit loop
.break (x == 10) ; force break
.endif
.eval x+1,x
.endloop
MACK3 .macro src1, src2, sum, k
!
! dst = dst + k * (src1 * src2)
.if k = 0
MPY src1, src2, src2
NOP
ADD src2, sum, sum
.else
MPY src1,src2,src2
MVK k,src1
MPY src1,src2,src2
NOP
ADD src2,sum,sum
.endif
.endm
MACK3 A0,A1,A3,0
MACK3 A0,A1,A3,100