I'm wondering in ARM assembly which instruction I can use to branch to an address or label stored in some memory address.
For example, we can use B LABEL to jump to LABEL. But now the destination can only be known during run time, and it is stored in some known memory place, is there something like B [address]?
Thanks!
is there something like B [address]?
No. Load the address into a register first, and then use BX
to jump to it:
@ In this example, R0 points to the address to jump to
LDR R1, [R0]
BX R1
You could also load the address directly into PC
(though I'm not sure if this is valid across all ARM architectures, so consult the relevant reference document):
@ In this example, R0 points to the address to jump to
LDR PC, [R0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With