Syntax: BLX <address>
BLX {<cond>} <register>
Operation: [MOV R14,PC] + Jump to specified address, switching to Thumb mode
Flags: T
This instruction is similar to BL, but also switches the processor into Thumb mode - it makes the processor break off from its normal sequential execution of instructions and jump to a new instruction at a designated location. By moving the contents of R14 back into PC, we can return to the original Branch instruction.
There are two forms of the instruction, when an address is specified directly the instruction is unconditional, whereas when the address is specified to be contained in a register it can be conditional. Both forms are only available in ARM architecture 5 and later.
Specifying <register> as R15 is unpredictable and should not be used.
Example:
.loop
SUB R0,R0,#1 ; R0 = R0 - 1
CMP R0,#0 ; is R0 = 0?
BNE loop ; if not, go back to start of loop
BLX subroutine ; otherwise, go to Thumb subroutine
...
.subroutine
BX R14 ; return to main ARM code
It is important that the contents of R14 are stored elsewhere prior to using this instruction. This can be done using a stack.
To return from the Thumb subroutine and switch back into ARM mode, use 'BX R14'.
|
|
|