Overview
An x86-64 CPU contains a set of 16 general-purpose registers storing 64-bit values. They are used to store integers and pointers.
1 Byte | 2 Bytes | 4 Bytes | 8 Bytes | Purpose |
---|---|---|---|---|
%al | %ax | %eax | %rax | Return value |
%bl | %bx | %ebx | %rbx | Callee saved |
%cl | %cx | %ecx | %rcx | 4th argument |
%dl | %dx | %edx | %rdx | 3rd argument |
%sil | %si | %esi | %rsi | 2nd argument |
%dil | %di | %edi | %rdi | 1st argument |
%bpl | %bp | %ebp | %rbp | Callee saved |
%spl | %sp | %esp | %rsp | Stack pointer |
%r8b | %r8w | %r8d | %r8 | 5th argument |
%r9b | %r9w | %r9d | %r9 | 6th argument |
%r10b | %r10w | %r10d | %r10 | Caller saved |
%r11b | %r11w | %r11d | %r11 | Caller saved |
%r12b | %r12w | %r12d | %r12 | Callee saved |
%r13b | %r13w | %r13d | %r13 | Callee saved |
%r14b | %r14w | %r14d | %r14 | Callee saved |
%r15b | %r15w | %r15d | %r15 | Callee saved |
Condition Codes
The CPU also maintains a set of single-bit condition code registers describing attributes of the most recent arithmetic or logical operation.
Code | Name | Description |
---|---|---|
CF | Carry flag | The most recent operation generated a carry out of the most significant bit. |
ZF | Zero flag | The most recent operation yielded zero. |
SF | Sign flag | The most recent operation yielded a negative value. |
OF | Overflow flag | The most recent operation caused a two’s-complement overflow. |
Bibliography
- Bryant, Randal E., and David O’Hallaron. Computer Systems: A Programmer’s Perspective. Third edition, Global edition. Always Learning. Pearson, 2016.