~/cheatsheets $ man 1 x86-64

X86-64(1)hachem.wtf manualX86-64(1)

name

x86-64 - registers, the calling convention, and instructions

synopsis

x86-64 [--registers] [--calling-convention-sysv-amd64] [--instructions] [--addressing-modes] [--conditions-jcc-after-cmp]

description

registers, the calling convention, and the instructions i actually type. everything is in intel/nasm order, so op dst, src.

registers

64     32     16    8      role (sysv)
rax    eax    ax    al     return value
rdi    edi    di    dil    arg 1
rsi    esi    si    sil    arg 2
rdx    edx    dx    dl     arg 3  (also 2nd return)
rcx    ecx    cx    cl     arg 4
r8     r8d    r8w   r8b    arg 5
r9     r9d    r9w   r9b    arg 6
r10    r10d   r10w  r10b   scratch
r11    r11d   r11w  r11b   scratch
rbx    ebx    bx    bl     callee-saved
rbp    ebp    bp    bpl    frame pointer (callee-saved)
rsp    esp    sp    spl    stack pointer
r12    r12d   r12w  r12b   callee-saved
r13    r13d   r13w  r13b   callee-saved
r14    r14d   r14w  r14b   callee-saved
r15    r15d   r15w  r15b   callee-saved

calling convention (sysv amd64)

linux and macos. windows x64 is different (rcx, rdx, r8, r9).

instructions

; int add(int a, int b) { return a + b; }   (sysv)
add:
    lea eax, [rdi + rsi]    ; a in edi, b in esi -> eax
    ret

addressing modes

conditions (jcc after cmp)

see also

gdb-lldb(1), graphics(1), interrupts(1), math(1), quantum(1), cheatsheets(1), hachem(1)

author

hachem <im@hachem.wtf>

~/cheatsheets $