Assembly Instructions

In x86-64 assembly language, instructions are the basic building blocks that represent operations to be performed by the CPU. An instruction consists of an operation mnemonic and zero or more operands.

Each instruction corresponds to a specific operation, such as moving data between registers, performing arithmetic operations, or branching based on conditions. There is a strong relationship between the assembly instruction and the opcode (the machine code instruction executed by the processor), and we can generally assume that there is a 1-to-1 correspondence.

Here are some common categories of x86-64 assembly instruction operations:

NOP

  • NOP: NOP doesn’t do anything and is therefore a great first instruction. Despite not doing anything, it still makes up around 6% of assembly code. It is commonly used for timing purposes, in debugging, building exploit code, and many other applications.

Data Movement Instructions

  • MOV: Move data from one location to another (e.g., from memory to a register, or between registers).
  • LEA: Load effective address (calculates an address and loads it into a register without accessing memory).

Arithmetic and Logic Instructions

  • ADD, SUB, MUL, DIV: Arithmetic operations (addition, subtraction, multiplication, division).
  • AND, OR, XOR, NOT: Logical operations (bitwise AND, OR, XOR, NOT).

Comparison Instructions

  • CMP: Compare two values without modifying any of them. It sets flags that are used by conditional jump instructions.

Control Flow Instructions

  • JMP: Unconditional jump to another part of the code.
  • Conditional jumps: JE (jump if equal), JNE (jump if not equal), JG (jump if greater), JL (jump if less), etc.

Procedure Call Instructions

  • CALL: Call a subroutine or function.
  • RET: Return from a subroutine.

Stack Instructions

  • PUSH: Push a value onto the stack.
  • POP: Pop a value from the stack.

String Instructions

  • MOVS: Move data from one location to another (used with strings).
  • LODS, STOS: Load and store data from/to memory and accumulator (used with strings).

These are just a few examples, and there are many more instructions in x86-64 assembly language. Each instruction is represented by a mnemonic (e.g., MOV, ADD) and may have one or more operands that specify the data involved in the operation. The operands can be registers, memory addresses, constants, or a combination of these. The order and types of operands are crucial in defining the behavior of each instruction.