Is it legal to do ldr r0,[r0] in ARM assembly?
When in doubt, always refer to the ARM Architecture Reference Manual, which can be found on arm.com. It says:
The destination register. The SP can be used. The PC can be used, provided the
instruction is either outside an IT block or the last instruction of an IT block.
If the PC is used, the instruction branches to the address (data) loaded to the PC.
In ARMv5T and above, this branch is an interworking branch, see Pseudocode details of
operations on ARM core registers on page A2-12.
It does not say that the destination register cannot be the same as the base register. I.e., the answer is YES, they can be the same.
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