Computer Architecture 1 / Chapter 3: Control Flow Instructions 1 / Jump Instruction

The JUMP Instruction

The jump (JUMP) instruction sets the PC to a specified value. The JUMP instruction format is:

jump imm=immediate

When this instruction is executed, LWCS will set the Program Counter to the immediate value. Thus, the jump instruction determines which instruction will be executed next.

Memory cells are not affected by this instruction.

More precisely,

if the following are true:

  • the PC at time t = i
  • instruction #i is jump imm=jump_to

then the PC at time (t + 1) = jump_to

For example,

if the following are true:

  • the PC at time 0 = 0
  • instruction #0 is jump imm=2

then the PC at time (0 + 1) = 2

Since 0 + 1 is 1, the PC at time 1 = 2

Try executing the JUMP instruction in the simulator:

Instructions
Memory Cells
Program Counter Time
0 0
LW Computer Simulator

Initially, the PC is 0, so instruction #0 is executed. In the JUMP instruction, imm is 2, so the PC is changed to 2. Thus, instruction #1 is skipped, and instruction #2, an ADDI instruction, is executed next.

Previous Lesson Next Lesson

Comments

Please log in to add comments