(reproduced) R14 also known as subroutine Connection register

Source: Internet
Author: User
Tags call back

R14 is also known as the subroutine Connection register (subroutine link register) or the connection register LR. When executing the BL subroutine call instruction, a backup of R15 (program counter PC) is obtained in R14.

In other cases, the R14 is used as the general register. Similarly, when an interrupt or an exception occurs, the corresponding packet registers r14_svc, R14_IRQ, R14_fiq, R14_abt, and R14_und are used to hold the return value of the R15.

Register R14 are commonly used in the following situations:

In each mode of operation, R14 can be used to save the return address of the subroutine (that is, R15 pc), when using the BL or BLX instructions to call the subroutine, the current value of the PC copy to R14, after executing the subroutine, and then copy the value of the R14 back to the PC, you can complete the subroutine call back. The above description can be completed with the instructions:

1. Execute any one of the following instructions:

MOV PC,LR

BX LR

2, at the entrance of the subroutine, use the following instruction to deposit R14 to the stack:

STMFD sp! , {<REGS>,LR}

Corresponding, use the following command to complete the subroutine return:

LDMFD sp! , {<regs>,pc}

R14 can also be used as a general-purpose register.

As the ARM architecture uses a multistage pipelining technology, for ARM instruction sets, the PC always points to the address of the next two instructions of the current instruction, that is, the value of the PC is the address value of the current instruction plus 8 bytes.

(reproduced) R14 also known as subroutine Connection register

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.