X86-64 CPU Architecture and 64-bit GCC changes to program compilation processing

Source: Internet
Author: User

X86-64 CPU Architecture and 64-bit GCC changes to program compilation processing

Jochen1986
Reprint Please specify source: http://blog.csdn.net/youkawa/article/details/45458921

  1. Universal registers are all extended to 64 bits, with the register name preceded by R, such as RAX, RBX, RCX, RDX, RSI and RDI;
  2. The instruction pointer (instruction pointer), the base address pointer (base pointer), and the stack pointer
    Pointer) has also been extended to the four-bit, these special registers are called rip,rbp,rsprespectively;
  3. Added 8 General Register R8~R15;
  4. The pointer length is 64 bits i.e. 8-bytes length;
  5. The length of the push/pop instruction that involves the stack operation is 64 bits or 8-bytes length;
  6. function parameters mainly rely on 6 registers to pass, when the register is not enough to push the parameters into the stack storage. According to the order of storage parameters (from left to right) RDI, RSI, RDX, RCX, R8, R9;
  7. The maximum canonical address size is 0x00007fffffffffff.
  8. GCC allocates a function local variable to a multiple of 16 bytes , such as assigning Char a[15], then the local variable is stored back from the [rbp-0x10] address, and if Char a[17] is defined, the local variable is stored from the [rbp-0x20] address;
  9. GCC allocates space for function local variables in the following ways:
    (1) When the function internal calls other external functions (with a call command), using SUB RSP, 0xXX instruction allocation stack space, and then use MOV [rbp-x], 0xXX form into the stack, if there is no local variable initialization, And this variable is not used behind the function, and GCC does not open space for it.
    (2) When no other external functions are called inside the function, the prologue operation is performed (that is, the push RBP; mov RBP, RSP), there will be no SUB RSP, 0xXX instruction to open up the operation of the stack space, but directly using the MOV QWORD PTR [rbp-0xxx], 0xXX Way directly using the stack space;
    (3) When the function internal static call Lib library function, because at this time the called function is inside the heart function, so there is no call command, still in the way (2) operation.

X86-64 CPU Architecture and 64-bit GCC changes to program compilation processing

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.