Assembly is a low-level programming language that provides a way to write instructions that the CPU can execute directly, it’s closely related to machine code but uses human-readable mnemonics.

Registers

These are small storage locations within the CPU used for quick data manipulation, you can check some common 32-bit registers (similar 64-bit registers exist with the prefix ‘R’ like RAX) here:

  • EAX (Accumulator Register): This one is where you do most of your calculations. Like if you’re adding numbers or storing temporary results.
  • EBX (Base Register): Used as a base for various operations, like holding addresses or secondary data.
  • ECX (Counter Register): Keeps track of counts, such as in loops. When you need to repeat an operation a certain number of times, you use this.
  • EDX (Data Register): Used for extra data in operations, especially in multiplication and division where the results can be large.
  • ESI (Source Index) and EDI (Destination Index): Both used for string and memory operations. ESI points to the source data, and EDI points to where the data should go.
  • EBP (Base Pointer): Used to keep track of the base address of the current stack frame, which is useful for accessing function parameters and local variables.
  • ESP (Stack Pointer): Points to the top of the stack, which is a special area of memory used for storing temporary data, function parameters, return addresses, etc.
  • EIP (Instruction Pointer): Points to the next instruction that the CPU will execute.

Instructions and Operands

Instructions are commands that the CPU executes, they often involve moving data, performing arithmetic, and controlling the flow of the program. Operands are the data that these instructions operate on, which can be registers, memory addresses or constants.

Common instructions:

MOV: Moves data from one location to another.

ADD/SUB: Adds or subtracts values.

INC/DEX: Increments or decrements the value of a register.

PUSH/POP: Pushes data onto the stack or pops data off the stack.

CMP: Compares two values.

CALL/RET: Calls a procedure or returns from a procedure.

JMP: Jumps to another instruction.

Conditional Jumps:

JE: Jump if equal.

JNE: Jump if not equal.

JG: Jump if greater.

JL: Jump if less.

LEAVE A REPLY

Please enter your comment!
Please enter your name here