Untitled

 avatar
unknown
plain_text
a year ago
1.2 kB
6
Indexable
In x86-64 architecture, there are several general-purpose registers, and they play specific roles, especially when it comes to function parameters. Here's an overview:
General-purpose registers:

RAX - Accumulator
RBX - Base
RCX - Counter
RDX - Data
RSI - Source Index
RDI - Destination Index
RBP - Base Pointer
RSP - Stack Pointer
R8 to R15 - Additional registers in 64-bit mode

Special-purpose registers:

RIP - Instruction Pointer
RFLAGS - Flags register

Function parameters:
In the x86-64 System V AMD64 ABI (used by Linux and most Unix-like systems), the first six integer or pointer arguments to a function are passed in registers:

RDI: 1st argument
RSI: 2nd argument
RDX: 3rd argument
RCX: 4th argument
R8:  5th argument
R9:  6th argument

Any additional arguments are passed on the stack.
For floating-point arguments, XMM0 to XMM7 are used.
Other register roles:

RAX: Often used to store the return value of a function
RSP: Points to the top of the stack
RBP: Often used as a frame pointer in functions
RIP: Contains the address of the next instruction to be executed

In the context of system calls:

RAX: Contains the system call number
RCX: Contains the return address for SYSCALL
R11: Used by SYSCALL/SYSRET instructions
Editor is loading...
Leave a Comment