1
• This guide should give you enough background to read andunderstand (most) of the 64bit x86 assembly that gcc is likely to produce.
• x86 is apoorly-designed ISA. It’s a mess, but it is the most widely used ISA in theworld today.
• Itbreaks almost every rule of good ISA design
• Justbecause it is popular does not mean it’s good
• Inteland AMD have managed to engineer (at considerable cost) their CPUs so that thisugliness has relatively little impact on their processors’ design (more on thislater)
• There’sa nice example here
• http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax
2
16bit |
|
32bit |
|
64bit |
Description |
Notes |
|
AX |
|
EAX |
|
RAX |
The accumulator register |
|
|
BX |
|
EBX |
|
RBX |
The base register |
|
|
CX |
|
ECX |
|
RCX |
The counter |
|
|
DX |
|
EDX |
|
RDX |
The data register |
These can be used |
|
SP |
|
ESP |
|
RSP |
Stack pointer |
more or less |
|
|
|
|
|
|
|
interchangeably |
|
BP |
|
EBP |
|
RBP |
Points to the base of the stack frame |
| |
|
|
|
| ||||
|
|
Rn |
|
RnD |
(n = 8...15) General purpose registers |
|
|
SI |
|
ESI |
|
RSI |
Source index for string operations |
|
|
DI |
|
EDI |
|
RDI |
Destination index for string operations |
|
|
IP |
|
EIP |
|
RIP |
Instruction Pointer |
|
|
|
FLAGS |
|
Condition codes |
|
|
Differentnames (e.g. ax vs. eax vs. rax) refer to different parts of the same register