Some differences between ARM commands LDR and ADR

Source: Internet
Author: User
Tags sub command

LDR is a command in ARM and also a pseudo command.

When LDR, = imd // r is used as the register, imd is the immediate number

LDR is a pseudo command. The compiler determines whether to use the ldr command or mov or mvn command based on the size of the number of immediate values.

When imd can be operated by mov or mvn, it is translated into an mov or mvn command. When imd is greater than mov or mvn, the compiler will store imd in a memory unit, and then use a ldr command to load the value of this memory unit into the register.

LDR r, label, and LDR, = label:

LDR, = label will load the value represented by label into the Register, while LDR and label will use label as the address and load the value from the address pointed by label to the Register.

For example, if the label value is 0x8000, LDR, = label will load 0x8000 to the Register, while LDR and label will load the value at memory 0x8000 to the Register.

ADR and ADRL pseudocommands:

The ADR and ADRL commands are used to load an address into a register.

ADR reads pseudocommands from a small range of addresses. The ADR command reads the address value of the PC relative offset to the Register. During compilation of the source program, the ADR pseudo command is replaced by the compiler in a suitable command. Generally, the compiler uses an ADD or SUB command to implement the ADR pseudo command function, if a command cannot be used for implementation, an error is generated. The address range that can be loaded. The value range is-1020 ~ when the byte is aligned ~ 1020. When non-Word Alignment occurs ~ In the range of 255.

ADRL is an address read instruction in a medium range. It will be translated into two commands by the compiler. If two commands cannot be used, an error is generated.

The address range that can be loaded by ADRL is-64 kB ~ when non-byte alignment occurs ~ 64 KB to 64 KB;-kb to-KB ~ Between kb.

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.