Skip to content

Instantly share code, notes, and snippets.

@nxnfufunezn
Forked from i80and/x8664-asm-cheetsheet.txt
Created June 15, 2016 04:13
Show Gist options
  • Save nxnfufunezn/81e3533f066f45f8ce4e6fb3cfc9874c to your computer and use it in GitHub Desktop.
Save nxnfufunezn/81e3533f066f45f8ce4e6fb3cfc9874c to your computer and use it in GitHub Desktop.
x86-64 asm cheatsheet
Registers
Caller-saved Callee-saved
RAX RCX RSP RDI RSI RDX R8 R9 R10 R11 RBP RBX R12 R13 R14 R15
Args: RDI, RSI, RDX, RCX, R8, R9, XMM0–7
Return: RAX
Simple Compile
yasm -f macho64 foo.asm && gcc foo.c foo.o -Wall -Wextra -g -O1
Template
section .text
global _func
_func:
push rbp
mov rbp,rsp
pop rbp
ret
If you don't push/pop, the stack gets misaligned. If you do, it's aligned to
16-byte boundary. If not: 8-byte.
https://github.com/webmproject/libvpx/blob/master/vpx_ports/x86_abi_support.asm
https://en.wikipedia.org/wiki/X86_instruction_listings
http://www.agner.org/optimize/instruction_tables.pdf
http://www.agner.org/optimize/microarchitecture.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment