ATPCS-ARM register and value transfer rules

Source: Internet
Author: User
For the arm system, the mix CILS between functions written in different languages follows the atpcs (ARM-thumb procedure call standard ), atpcs mainly defines the parameter transfer rules for function calls and how to return parameters from functions. For details about atpcs, see section 2.1 of the ads1.2 online books developer guide. Rules for using the simple atpcs register: 1. the subroutine passes through the Register R0 ~ R3 to pass parameters. The register can be recorded as a0 ~ A3. The called subroutine does not need to recover the register R0 ~ before returning ~ R3 content. 2. In the subroutine, use R4 ~ R11 to save the local variable, then register R4 ~ R11 can be recorded as V1 ~ V8. If V1 ~ is used in the subroutine ~ Some registers of V8, the values of these registers must be saved when the subroutine enters, and the values of these registers must be restored before return. These operations are not required for the registers not used in the subroutine. in the Thumb program, you can only use the register R4 ~ R7 to save local variables. 3. register R12 is used as the scratch register between subprograms and is recorded as an IP address. This usage rule is often used in subprograms. 4. register R13 is used as the data stack pointer and recorded as sp. in the subroutine, register R13 cannot be used for other purposes. the SP value in the register must be the same as that in the exit subroutine. 5. register R14 is used as the connection register and recorded as LR; it is used to save the return address of the subroutine. If the return address is saved in the subroutine, R14 can be used for other purposes. 6. register R15 is a program counter and is recorded as a PC. It cannot be used for other purposes. 7. the registers in atpcs are predefined in the arm compiler and assembler. rules for returning subroutine results 1. when the result is a 32-bit integer, it can be returned through the R0 register. 2. when the result is a 64-bit integer, it can be returned through R0 and R1, and so on. 3. when the result is a floating point number, it can be returned through the floating point register F0, D0 or S0. 4. when the result is a composite floating point, you can send Memory f0-fN or D0 ~ DN to return. 5. For more bits, the results must be passed by calling the memory.

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: 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.