Understanding of absolute addressing relative addressing ldr,adr in arm

Source: Internet
Author: User

LDR: is a location-related, absolute addressing, followed by the location of the value of the program is compiled when the position is determined.

For example, when a program is executed inside stepping stone, if the LDR pc is used, =copy_proc_beg the program is to pay the PC the absolute address of the Copy_proc_beg, that is, the address 0x30000000 at compile time, plus the offset address. , to achieve the jump.

The actual addressing space of the LDR pseudo instruction is 32 bits


Adr:adr is based on a PC or register, relative addressing, so this instruction is read based on the instructions at the time of the PC address + or-offset address, so it is location-independent, regardless of where to perform, the read address is based on the PC offset.

For example, start MOV r0, #10

ADR R4,start is compiled with sub r4,pc, #0xc because the current PC value is +8 for this instruction, so -0xc

However, the address space of ADR is only 4kb before and after, and must be in the same code segment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.