2.4 KiB
2.4 KiB
Assembly
Labels
.cfi_startproc
: marks the beginning of a function.cfi_endproc
: marks the end of a function.L{A-Z}*{0-9}+
: local label.L{0-9]+
: jump target.L{A-Z}+{0-9}+
: other purposeFB
: function beginFE
: function end
AT&T
- source comes before destination
- mnemonic suffixes indicate the size of the operands (q for quad, etc.)
- registers are prefixed with % and immediate values with $
- effective addresses are in the form DISP(BASE, INDEX, SCALE) (DISP + BASE + INDEX * SCALE)
- Indirect jump/call operands indicated with * (as opposed to direct).
Resources
- Opcodes: https://www.felixcloutier.com/x86/index.html
- General Intel instructions: https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.html
- More performance oriented: https://www.agner.org/optimize/
Registers
Overview
| --- | --- | --- | --- |
64-bit register | Lower 32 bits | Lower 16 bits | Lower 8 bits |
---|---|---|---|
rax | eax | ax | al |
rbx | ebx | bx | bl |
rcx | ecx | cx | cl |
rdx | edx | dx | dl |
rsi | esi | si | sil |
rdi | edi | di | dil |
rbp | ebp | bp | bpl |
rsp | esp | sp | spl |
r8 | r8d | r8w | r8b |
r9 | r9d | r9w | r9b |
r10 | r10d | r10w | r10b |
r11 | r11d | r11w | r11b |
r12 | r12d | r12w | r12b |
r13 | r13d | r13w | r13b |
r14 | r14d | r14w | r14b |
r15 | r15d | r15w | r15b |
Calling Conversions
- Args:
RDI, RSI, RDX, RCX, R8, R9
- System Calls:
R10
(instead ofRCX
)
- System Calls:
- Return:
RAX
- Callee-Saved:
RBX, RBP, R12, R13, R14, R15
- Caller-Saved:
RAX, RCX, RDX, RDI, RSI, R8, R9