0Pricing
Reverse Engineering & Binary Analysis Basics · Lesson

Control Flow and Function Calls

Learn about conditional jumps, loops, and the mechanics of function calls, including stack usage.

Control Flow: Making Programs Smart

In assembly, instructions usually run one after another. This is called sequential execution. But real programs need to make decisions, repeat actions, and call functions.

This is where control flow comes in! It's how a program changes its execution path based on conditions, creating loops and calling subroutines.

Conditional Jumps: If-Statements

Conditional jumps are like if statements in high-level languages. They let your program execute different code blocks based on a condition.

The CMP instruction compares two values and sets CPU flags. Then, jump instructions like JE (Jump if Equal) or JNE (Jump if Not Equal) check these flags to decide whether to jump.

; Example: if (EAX == EBX) goto equal_label;
MOV EAX, 10
MOV EBX, 10
CMP EAX, EBX    ; Compare EAX and EBX
JE  equal_label ; Jump if Equal
; Code here runs if EAX != EBX
JMP end_label

equal_label:
; Code here runs if EAX == EBX

end_label:
; Program continues

All lessons in this course

  1. x86/x64 Assembly Basics
  2. Registers and Memory Operations
  3. Control Flow and Function Calls
  4. The Stack & Calling Conventions
← Back to Reverse Engineering & Binary Analysis Basics