Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same source and destination register in ldr

Tags:

assembly

arm

Is it legal to do ldr r0,[r0] in ARM assembly?

like image 670
tangrs Avatar asked Oct 26 '25 14:10

tangrs


1 Answers

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.

like image 132
Variable Length Coder Avatar answered Oct 29 '25 18:10

Variable Length Coder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!