Skip to content

Instantly share code, notes, and snippets.

@i80and
Last active September 17, 2019 15:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save i80and/524b526471b7d3d5c2ab to your computer and use it in GitHub Desktop.
Save i80and/524b526471b7d3d5c2ab 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