AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
Syntax:          BL {<cond>} <address>
Operation:     [MOV R14,PC] + Jump to specified address
Flags:          Unaffected

This instruction is analogous to the BASIC GOSUB statement - 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.

When used in conjunction with the normal condition codes, this instruction becomes the basis of conditional branching.

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
BL   subroutine     ; otherwise, go to subroutine
...     
.subroutine     
MOV  PC,R14          ; return to main code

It is important that the contents of R14 are stored elsewhere prior to using this instruction. This can be done using a stack.
On systems running in 26 bit mode (where available) the variant 'MOVS PC,R14' would also restore the status flags which prevailed on entry. This does not work in 32 bit mode as the status bits are held seperately, you must use 'MOV PC,R14' and restore the status bits manually where required.

[sh-index] Back to list of manuals