Assembler User GuidePreface Overview of the Assembler Overview of the ARM Architecture Structure of Assembly Language Modules Writing ARM Assembly Language About the Unified Assembler Language Register usage in subroutine calls Load immediate values Load immediate values using MOV and MVN Load immediate values using MOV32 Load immediate values using LDR Rd, =const Literal pools Load addresses into registers Load addresses to a register using ADR Load addresses to a register using ADRL Load addresses to a register using LDR Rd, =label Other ways to load and store registers Load and store multiple register instructions Load and store multiple register instructions in A Stack implementation using LDM and STM Stack operations for nested subroutines Block copy with LDM and STM Memory accesses The Read-Modify-Write operation Optional hash with immediate constants Use of macros Test-and-branch macro example Unsigned integer division macro example Instruction and directive relocations Frame directives Exception tables and Unwind tables Assembly language changes after RVCT v2.1 Condition Codes Using the Assembler Symbols, Literals, Expressions, and Operators VFP Programming Assembler Command-line Options ARM and Thumb Instructions VFP Instructions Directives Reference Via File Syntax
Test-and-branch macro example
4.22 Test-and-branch macro example
You can use a macro to perform a test-and-branch operation.
In ARM code in any processor and in Thumb code in processors before ARMv6T2, 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
This macro can be invoked as follows:
test TestAndBranch NonZero, r0, NE ... ... NonZero
After substitution this becomes:
test CMP r0, #0 BNE NonZero ... ... NonZero
of your data.