Skip to content

Instantly share code, notes, and snippets.

@0x61nas
Last active February 10, 2024 06:35
Show Gist options
  • Save 0x61nas/181649aea03e7c863748d69f1b63a797 to your computer and use it in GitHub Desktop.
Save 0x61nas/181649aea03e7c863748d69f1b63a797 to your computer and use it in GitHub Desktop.
Instruction Operands Description
MOV dist, source Copy the data from the source to the distnation register or memory
INC dist Increment the distnation register or memory by one
DEC dist Decrement the distnation register or memory by one
JNZ dist(label) Tests the value of Zero Flag and jump to the distnation if its not set(a.k.a. set o 0)
JMP dist Always jump to its operand
ADD dist, source Add the source value to the distnation
NOP n/a No operation, it takes some time to execute
NEG dist Take a positive value and make it nigative
MOVSX dist, source Move with sign extension

MOV

The MOV instruction is used to move copy a byte(1-bit), word(116-bit), double word(32-bit), or quad word(64-bit} from the source to the distnation.

Syntax

Copy the data from register into anouther register with the same size

  mov <dist>, <source reg>

Copy the data from memory to a register

  mov <dist>, [<source mem>]

Copy the data with the specified size from the source to the distnation memory

  mov <size> [<dist mem>], <source>

Examples

Copy 73 hex immediate value to RAX register

  mov rax, 73h

Copy data from RAX register to RCX register

  mov rcx, rax

Copy the memory address to RSI register

  mov rsi, mylove

Copy the actual data from the memory address to RAX register

  mov rax, [mylove]

Copy one-byte from the memory to AL register

  mov al, [mylove]

Copy one byte to the last place in memory location

  mov byte [mylove], 'd'

Note

You can't use the MOV instruction to copy data directly from one address in memory to different address in memory. To do that you need to two separate MOV instructions: the first is to move data from memory to some register, and the second is to move data from that register to the distenitaon memory.

INC

The INC instruction is used to increment the distenation value by one.

Syntax

  inc <dist>

Examples

  mov ebx, 15h
  inc ebx ; 16h
  mov eax, 0ffff_ffffh
  inc eax ; 0

Note

Notice that in the second example the OF didn't set, and this because the the INC instruction work with unsigned numbers and OF is for signed numbers.

DEC

The DEC instruction is used to decrement the distenation value by one.

Syntax

  dec <dist>

Examples

  mov ebx, 15h
  dec ebx ; 14h
  mov eax, 0h
  dec eax ; 0xffff_ffffh

Note

Notice that in the second example the OF didn't set, and this because the the DEC instruction work with unsigned numbers and OF is for signed numbers.

JNZ

The JNZ instruction is used to change the flow of machine instructions in your programs based on the ZF value.

If the ZF is set(a.k.a. equal 1) this instructions doesn't do anything and your program excuation continue as nomal. If the ZF isn't set(a.k.a. is equal to 0) this instruction will change your excuation to a new distenation in your program.

Syntax

  jnz <dist>

Examples

  mov rax, 5
  do_more:
    dec rax
    jnz do_more

JMP

The JMP instruction dose not look at the flags. When executed, it always jump to its operand.

Syntax

  jmp <dist>

Examples

  xor rax, rax
  work:
    inc rax
    jmp work

ADD

The ADD instruction is used to add a value to the distenation.

Syntax

  add <dist>, <source>
  add <size> [<mem dist>], <source>

Examples

  mov rax, 3
  add rax, 3 ; 6
  mov rbx, mylove
  add byte [rbx], 32

NEG

The NEG instructoin take a positive value and negate that value, i.e. make it negative. It does so by generating the two's complement from of the positive value.

Syntax

  neg <dist>

Examples

  mov rax, 8
  neg rax ; -8

MOVSX

MOVSX means "Move with Sign Extension," and it was introduced with i386 family of CPUs, and because Linux will not run on anything older than 386 you can assume that the MOVSX is always available.

Note

MOVSX is significantly different from MOV in that its operands may be of different sizes.

Syntax

  movsx <dist>, <source>

Examples

  mov ax, -32
  movsx rbx, ax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment