Asm Cheat Sheet



Registers

64 bit32 bit16 bit8 bit
A (accumulator)RAXEAXAXAL
B (base, addressing)RBXEBXBXBL
C (counter, iterations)RCXECXCXCL
D (data)RDXEDXDXDL
RDIEDIDIDIL
RSIESISISIL
Numbered (n=8.15)RnRnDRnWRnB
Stack pointerRSPESPSPSPL
Frame pointerRBPEBPBPBPL

When I made my first steps coding in the programming language Intel Assembly x86 I was looking for a compact list containing all instructions. Because I couldn't find any I created my own cheat sheet: includes most instructions (transfer, arithmetic, logic, jumps.) includes a diagram of the registers (EAX, EDX, ECX, EBX) and flags. NASM Intel x86 Assembly Language Cheat Sheet Instruction Effect Examples Copying Data mov dest,src Copy src to dest mov eax,10 mov eax,2000 Arithmetic add dest,src dest = dest + src add esi,10 sub dest,src dest = dest – src sub eax, ebx mul reg edx:eax = eax. reg mul esi div reg edx = edx:eax mod reg eax = edx:eax reg.

As well as XMM0 . XMM15 for 128 bit floating point numbers.

Calling C

Put function arguments (first to last) in the following registers (64 bitrepresentations): RDI, RSI, RDX, RCX, R8, R9, then push to stack (in reverse,has to be cleaned up by the caller!) XMM0 - XMM7 for floats

Teraterm log file name format. Return values are stored in RAX (int) or XMM0 (float)

RBP, RBX, R12, R13, R14, R15 will not be changed by the called function, allothers may be Virtual dj 9 full crack.

Align stack pointer (RSP) to 16 byte, calling pushes 8 bytes!

Keep in mind that strings (in C) are 0-terminated

Like in a normal C program, the label that is (de facto) called first ismain, with the args argc (argcount) in RDI, and the char** argv in RSI(the commandline arguments as in C's main function).

Data

Definition sizeDefinition instruction
8 bitdb
16 bitdw
32 bitdd
64 bitddq/do
floatdd
doubledq
extended precisiondt

Conditionals

cmp op1, op2 -> mimics sub op1, op2 but only changes the zero and carry flagfor comparing.

Prefixes:

  • j~ x -> jump to x if ~
  • cmov~ x, y -> conditional mov x, y if ~
  • setc~ x -> set x to 1 if ~, x is 8 bit reg

Many suffixes, including:

  • a (above, >)
  • ae (above or equal, >=)
  • b (below, <)
  • be (below or equal, <=)
  • e (equal, =)
  • ne (not equal, !=)

Program structure

  • global <entry> -> exposes entry point
  • extern <function> -> declares a function in another linked .o file (e.g. Cfunction, other asm file)
  • section <sectiontype> -> sets section, usually:
    • .text -> program code
    • .data -> data
Arm64 asm cheat sheet

The program entry point of a standalone program is the label _start. Whencompiled with gcc, C provides _start, which inits and then jumps to main,which should then be implemented by the program.

Syscalls

  • put syscall number in EAX (e.g. on Linux: 60 for exit, 1 for write to stdout)
  • put arguments in the registers (see above) like when calling a C function
  • execute the syscall instruction

Assemble

  • Assemble: nasm -felf64 -o <object> <filename>
  • Link with ld: ld -o <output> <object>
  • Link with gcc: gcc -o <output> <object>

Asm Cheat Sheet Oracle

Sources

Oracle Asm Command Cheat Sheet

  • Forked from: mpdrescher
  • Main: NASM Tutorial
  • Registers: Assembly registers
  • Conditionals: Jumps and loops (de)