Skip to content

Instantly share code, notes, and snippets.

@0x61nas
Last active February 11, 2024 11:41
Show Gist options
  • Save 0x61nas/f94c73546ebd97b1018ae822399c1109 to your computer and use it in GitHub Desktop.
Save 0x61nas/f94c73546ebd97b1018ae822399c1109 to your computer and use it in GitHub Desktop.
The general purpose registers(GPRs) in x64 processors
All x86-64 processors contain 16 64-bit wide general purpose registers.
Functions use thes registers to perform integer arithmetic, bitwise logical operations, comparisoins, address calculations, and data transfers.
A function can also store an intermediate or temporary result in one of those registres instead of saving it to memory.
╭──────────────────────────────────Quad Word────────────────────────────────────╮
│ ╭─────────────────Double Word────────────────╮│
│ │ ╭───────Word────────╮││
│ │ │ ╭─Byte──╮│││
╵ ╵ ╵ ╵ ╵╵╵╵
┇63 ┇31 ┇15 ┇7 0┃
┇ ┇ ┇ ┇ ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RAX ┇ EAX ┇ AX ┇ AL │╎┆┃ RAX
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RBX ┇ EBX ┇ BX ┇ BL │╎┆┃ RBX
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RCX ┇ ECX ┇ CX ┇ CL │╎┆┃ RCX
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RDX ┇ EDX ┇ DX ┇ DL │╎┆┃ RDX
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RSI ┇ ESI ┇ SI ┇ SIL │╎┆┃ RSI
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RDI ┇ EDI ┇ DI ┇ DIL │╎┆┃ RDI
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RBP ┇ EBP ┇ BP ┇ BPL │╎┆┃ RBP
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ RSP ┇ ESP ┇ SP ┇ SPL │╎┆┃ RSP
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R8 ┇ R8D ┇ R8W ┇ R8B │╎┆┃ R8
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R9 ┇ R9D ┇ R9W ┇ R9B │╎┆┃ R9
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R10 ┇ R10D ┇ R10W ┇ R10B │╎┆┃ R10
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R11 ┇ R11D ┇ R11W ┇ R11B │╎┆┃ R11
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R12 ┇ R12D ┇ R12W ┇ R12B │╎┆┃ R12
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R13 ┇ R13D ┇ R13W ┇ R13B │╎┆┃ R13
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R14 ┇ R14D ┇ R14W ┇ R14B │╎┆┃ R14
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━┫
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┐┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╮┆┃
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┐╎┆┃
┃ R15 ┇ R15D ┇ R15W ┇ R15B │╎┆┃ R15
┃ ┇ ┇ ┠┄┄┄┄┄┄┄┄┘╎┆┃
┃ ┇ ┠╌╌╌╌╌╌╌╌╌╌╂╌╌╌╌╌╌╌╌╌╯┆┃
┃ ┠┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┘┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━━┛
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment