Hello my friends, welcome to the week 8 of SPO600(Software Portability and Optimization) blog. In this blog, let’s talk about the registers in the x86_64 framework.
Instruction
Remember that the x86_64 processor family is based on a long long series of processors that date back to the 1970s. So originally on these processors we had a small number of registers, like the X and Y register of the 6502 assembly language on the x86 family. The mean registers in x86_64 are A, B, C, D registers. Through the years, the register family has been extended, we still have the A, B, C, D registers but now they are called RAX, RBX, RCX, RDX which mean the extended registers of A, B, C, D and they are 64-bits wide. Beyond this, we also get RBP which means the register base pointer to store the start of the stack, and then we get RSP which stores the stack pointer, RSI and RDI are typically used for copy operation. RSI stores the source index which is pointing to the source that you want to copy and the RDI stores the destination index where you want to place the copy to. X64 also added another 8 (R8-R15) registers. Since some of x86’s registers have special implicit meanings and are not used as general-purpose.
Passing Argument
In this blog, I only focus on integer arguments. For example, 7 integer arguments to a function are passed in registers. The first integer is placed in RDI, the second integer is placed in RSI, the third integer is placed in RDX, the fourth integer is placed in RCX, and then R8 and R9. only the 7th integer is passed on the stack.
Reflection
This is the second week that we step on X86_64 and the AArch64 framework. In this blog we only discuss the registers in x86_64 but in the future I will also blog more about the AArch64 framework. This week I learned that modern processors are super fast because they often "guess" the outcome of an operation and store the results of "guess" into the registers that we talked about above.
Top comments (0)