You can use a macro to perform a test-and-branch operation.
In A32 code, a test-and-branch operation requires two instructions to implement.
You can define a macro such as this:
MACRO$label TestAndBranch $dest, $reg, $cc$label CMP $reg, #0 B$cc $dest MEND
The line after the
MACRO directiveis the macro prototype statement. This definesthe name (
TestAndBranch) you use to invoke themacro. It also defines parameters ($label, $dest, $reg, and $cc).Unspecified parameters are substituted with an empty string. Forthis macro you must give values for $dest, $reg and $cc toavoid syntax errors. The assembler substitutes the values you giveinto the code.
This macro can be invoked as follows:
test TestAndBranch NonZero, r0, NE ... ...NonZero
After substitution this becomes:
test CMP r0, #0 BNE NonZero ... ...NonZero