Course contentsShow
← Computer Science
Lesson 1099 of 2,87225. Computer Architecture FoundationsFree lesson

Unconditional Jumps and Labels

Controlling program flow with JMP instructions and understanding label-based addressing.

Unconditional Jumps and Labels

You'll learn how to make your program jump to different parts of code using JMP instructions and labels.

The Core Idea

In assembly language, programs normally execute instructions sequentially—one after another, top to bottom. But what if you need to skip ahead, loop back, or branch to a different section? That's where unconditional jumps come in.

A JMP instruction tells the CPU: "Stop executing sequentially and immediately jump to this specific location in the program." It's called "unconditional" because the jump always happens—no questions asked, no conditions checked.

To specify where to jump, we use labels—human-readable names that mark specific locations in your code. Labels act like bookmarks or street addresses for instructions.

How It Works

Think of labels as named checkpoints in your program. When you write:

start:
    MOV R1, #5
    JMP end
    ADD R1, #10    ; This line gets skipped!
end:
    SUB R1, #2

The CPU executes MOV, then immediately jumps to the end: label, completely skipping the ADD instruction. The program counter (PC) gets directly set to the address marked by end:.

Why This Matters

Unconditional jumps are fundamental building blocks for:

  • Creating loops (jump back to repeat code)
  • Implementing function calls
  • Building more complex control structures
  • Organizing code into logical sections

Unlike comparison or test instructions you've learned, JMP doesn't look at any flags or conditions—it just goes.

Key Takeaway: Unconditional jumps (JMP) transfer program control directly to a labeled location without checking any conditions, allowing you to break free from sequential execution.