AMD64


x86-64 (also known as x64, x86_64, AMD64, and Intel 64) is a 64-bit version of the x86 instruction set.

Registers

64 32 16 8L 8H Description
rax eax ax al ah Accumulator
rbx ebx bx bl bh Base
rcx ecx cx cl ch Count
rdx edx dx dl dh I/O address
rsi esi si sil   Source index
rdi edi di dil   Destination index
rbp ebp bp bpl   Base pointer
rsp esp sp spl   Stack pointer
r8 r8d r8w r8b    
r9 r9d r9w r9b    
r10 r10d r10w r10b    
r11 r11d r11w r11b    
r12 r12d r12w r12b    
r13 r13d r13w r13b    
r14 r14d r14w r14b    
r15 r15d r15w r15b    
rip eip ip     Instruction Pointer
RFLAGS EFLAGS FLAGS      

RFLAGS Register

The RFLAGS register stores flags used for results of operations and for controlling the processor.

Mnemonic Bit Name Description
CF 0 Carry Operation generated a carry or borrow
PF 2 Parity Last byte has even number of 1’s, else 0
AF 4 Adjust Denotes binary coded decimal in-byte carry
ZF 6 Zero Result was 0
SF 7 Sign Most significant bit of result is 1
OF 11 Overflow Overflow on signed operation
DF 10 Direction Direction string instructions operate (increment or decrement)
ID 21 Identification Changeability denotes presence of cpuid instruction

Application Binary Interface

Linux

Windows

Jump

The jump instructions allow the programmer to (indirectly) set the value of the rip register, with all of the jump instructions, with the exception of jmp, being conditional jumps.

Mnemonic Signage Flags Description
jmp     Unconditional jump
jo   OF = 1 Jump of overflow
jno   OF = 0 Jump of not overflow
js   SF = 1 Jump if signed
jns   SF = 0 Jump if not signed
je   ZF = 1 Jump if equal
jz   ZF = 1 Jump if zero
jne   ZF = 0 Jump if not equal
jnz   ZF = 0 Jump if not zero
jb unsigned CF = 1 Jump if below
jnae unsigned CF = 1 Jump if not above or equal
jc unsigned CF = 1 Jump if carry
jnb unsigned CF = 0 Jump if not below
jae unsigned CF = 0 Jump if above or equal
jnc unsigned CF = 0 Jump if not carry
jbe unsigned CF = 1 or ZF = 1 Jump if below or equal
jna unsigned CF = 1 or ZF = 1 Jump if not above
ja unsigned CF = 0 and ZF = 0 Jump if above
jnbe unsigned CF = 0 and ZF = 0 Jump if not below or equal
jl signed SF <> OF Jump if less
jnge signed SF <> OF Jump if not greater or equal
jge signed SF = OF Jump if greater or equal
jnl signed SF = OF Jump if not less
jle signed SF <> OF or ZF = 1 Jump if less or equal
jng signed SF <> OF or ZF = 1 Jump if not greater
jg signed SF = OF and ZF = 0 Jump if greater
jnle signed SF = OF and ZF = 0 Jump if not less or equal
jp   PF = 1 Jump if parity
jpe   PF = 1 Jump if parity even
jnp   PF = 0 Jump if not parity
jpo   PF = 0 Jump if parity odd
jcxz   cx = 0 Jump if counter register is zero
jecxz   ecx = 0 Jump if counter register is zero
jrcxz   rcx = 0 Jump if counter register is zero

Move

Mnemonic Description
mov  
movzbw Byte to word; zero-extended.
movzbl Byte to long; zero-extended.
movzwl Word to long; zero-extended.
movsxd Word to long; sign-extension.

Test

The test instruction performs a bitwise AND on two operands.

test    %al, %al            ; set ZF to 1 if al == 0
jz      foo                 ; jump if ZF == 1

test    %al, %al            ; set ZF to 1 if al == 0
jnz     foo                 ; jump if ZF == 0

test    %eax, %eax          ; set SF to 1 if eax < 0
js      foo                 ; jump if SF == 1