x86 64 Registers

| 分类 Program  | 标签 Program_Structure 

Registers are the actual locations where CPU directly communicates. So when a context switch happens, the content of the registers of the currently running process is stored in the RAM and the registers of the next process is loaded from the RAM.

You can use gdb to check the content of registers when any instruction executed. info registers will displays content of all the registers and command like p $rbp will print the content of the register rbp. As the following command shows:

(gdb) info registers 
rax            0x0                 0
rbx            0x5555555551b0      93824992235952
rcx            0x0                 0
rdx            0x0                 0
rsi            0x5555555592a0      93824992252576
rdi            0x7ffff7fa57e0      140737353766880
rbp            0x0                 0x0
rsp            0x7fffffffdae0      0x7fffffffdae0
r8             0x0                 0
r9             0x19                25
r10            0x55555555601f      93824992239647
--Type <RET> for more, q to quit, c to continue without paging--
r11            0x246               582
r12            0x555555555080      93824992235648
r13            0x7fffffffdbc0      140737488346048
r14            0x0                 0
r15            0x0                 0
rip            0x7ffff7ddb083      0x7ffff7ddb083 <__libc_start_main+243>
eflags         0x202               [ IF ]
cs             0x33                51
ss             0x2b                43
ds             0x0                 0
es             0x0                 0
--Type <RET> for more, q to quit, c to continue without paging--
fs             0x0                 0
gs             0x0                 0

(gdb) p $rbp
$1 = (void *) 0x7fffffffdad0

For x86_64 CPU registers, the meaning of the most common used registers are shown below:

General Purpose Registers

64-bit 32-bit 16-bit 8 high bits 8 low bits Description
RAX EAX AX AH AL Accumulator
RBX EBX BX BH BL Base
RCX ECX CX CH CL Counter
RDX EDX DX DH DL Data
RSI ESI SI N/A SIL Source
RDI EDI DI N/A DIL Destination
RSP ESP SP N/A SPL Stack Pointer
RBP EBP BP N/A BPL Stack Base Pointer

Pointer Registers

64-bit 32-bit 16-bit Description
RIP EIP IP Instruction Pointer

References

x86 Assembly Guide

x86_64 CPU Registers


上一篇     下一篇