COREWAR

/
Step 12: Looping Back in Time with "JMP"
🎯Set Cell 0001 JMP A-value to -1 (jump 1 line up)(0/-1)

MISSIONS (30 STEPS)

CH.1: UI & MEMORY BASICS (1-6)
BASIC★☆☆
Step 1: The "STEP" Button That Advances Time
🔒
BASIC★☆☆
Step 2: Process Termination and Restoring with "RESET"
🔒
BASIC★☆☆
Step 3: "Edit Mode" vs. "Running Mode"EDIT
🔒
BASIC★☆☆
Step 4: The Three Rooms of a Memory Box (Changing B)EDIT
🔒
BASIC★☆☆
Step 5: Modifying Both the Left Room (A) and Right Room (B)EDIT
🔒
BASIC★☆☆
Step 6: Literal Numbers (#) vs. Relative Addresses ($)EDIT
CH.2: CORE INSTRUCTIONS (7-13)
🔒
ARITHMETIC★☆☆
Step 7: Observing the "ADD" Instruction
🔒
ARITHMETIC★☆☆
Step 8: Changing the Number to Add (A-Field)EDIT
🔒
ARITHMETIC★☆☆
Step 9: Changing the Target Address (B-Field)EDIT
🔒
ARITHMETIC★☆☆
Step 10: Using the Subtraction Instruction "SUB"EDIT
🔒
BASIC★☆☆
Step 11: Copying an Entire Box with "MOV"EDIT
🔒
CONTROL★☆☆
Step 12: Looping Back in Time with "JMP"EDIT
🔒
CONTROL★☆☆
Step 13: Build Your First Program (Automatic Counter)EDIT
CH.3: VON NEUMANN & DIGITAL LIFE (14-18)
🔒
BASIC★☆☆
Step 14: Why Does "DAT" Become a Bomb?EDIT
🔒
BASIC★☆☆
Step 15: Copying Your Own Instruction (Code = Data)EDIT
🔒
BASIC★☆☆
Step 16: Observation: Stepping Through "Imp", the Oldest Digital Organism
🔒
BASIC★☆☆
Step 17: Modifying the Imp (Copy Destination Experiment)EDIT
🔒
ARITHMETIC★★☆
Step 18: Understanding Indirect Addressing (@ Pointers)EDIT
CH.4: CLASSIC ARCHETYPES (19-24)
🔒
STRATEGY★★☆
Step 19: Observation: Dissecting the "Dwarf" Bomber Step-by-Step
🔒
STRATEGY★★☆
Step 20: Modifying Dwarf (Changing the Bombing Interval)EDIT
🔒
STRATEGY★★☆
Step 21: First Combat: Tune Your Bomb Interval to Destroy the TargetEDIT
🔒
CONTROL★★☆
Step 22: Observation: The "SPL" Split Instruction and Mitosis
🔒
CONTROL★★☆
Step 23: Finding Enemies with Conditional Skip "SEQ / CMP"EDIT
🔒
STRATEGY★★☆
Step 24: Stopping an Imp with a Pre-Decrement "Imp-Gate"EDIT
CH.5: BATTLE EVOLUTION (25-30)
🔒
STRATEGY★★☆
Step 25: [Stone] High-Speed Bomber and Step Size TuningEDIT
🔒
STRATEGY★★☆
Step 26: [Paper] Observing the Self-Replicating Swarm "Mice"
🔒
STRATEGY★★★
Step 27: [Modifying Paper] Tune Clone Dispersal Distance to Overwhelm StoneEDIT
🔒
STRATEGY★★☆
Step 28: [Scissors] Tuning Scanner Stride to Shred PaperEDIT
🔒
STRATEGY★★★
Step 29: [Trap] Abducting Enemy Processes with "Vampire"EDIT
🔒
STRATEGY★★★
Step 30: Graduation Exam: Tune Your Warrior and Win the Final BattleEDIT
🟢 EDIT MODE (Click cells to modify)
[Addr][Opcode][A (Left)][B (Right)]
📦 DATA / BOMB (DAT)
0000
▼MOV
#
$
0001
▼MOV
<
<
👈 EDIT
0002
↺JMN
$
$
0003
❖SPL
@
#
0004
+ADD
#
$
0005
↺JMP
$
$
0006
■DAT
$0
$0
++ ADD ROW
0007
■DAT
$0
$0
0008
■DAT
$0
$0
0009
■DAT
$0
$0
0010
■DAT
$0
$0
0011
■DAT
$0
$0
0012
■DAT
$0
$0
0013
■DAT
$0
$0
0014
■DAT
$0
$0
0015
■DAT
$0
$0
0016
■DAT
$0
$0
0017
■DAT
$0
$0
0018
■DAT
$0
$0
0019
■DAT
$0
$0
0020
■DAT
$0
$0
0021
■DAT
$0
$0
0022
■DAT
$0
$0
0023
■DAT
$0
$0
0024
■DAT
$0
$0
0025
■DAT
$0
$0
0026
■DAT
$0
$0
0027
■DAT
$0
$0
🏟️ARENA (20 ROWS)SCOPE: 0000 - 0019
[CORE MEMORY 800 CELLS (20 ROWS × 40 COLS)]1:1 Row Synced with Editor
TASKS: 0
CYC: 0
📖 LECTURE NOTE // STEP 12 OF 30Chapter 2: Core Instructions & Autonomous Loops⏱ 5 min read
📖 Lecture Note: Computer Science & Artificial Life Principles Behind This Experiment

Unconditional Branching ("JMP") and Loops: Turning Finite Space into Infinite Time

How control-flow instructions hijack the Program Counter to create repetition, the engine of all algorithms

#JMP (Jump)#Control Flow#Program Counter Manipulation#Infinite Loop#Structured Program Theorem
🔬Step 12: Looping Back in Time with "JMP"

So far, our programs stopped after a few lines when hitting DAT. To keep a program alive forever, use the JMP (Jump) instruction to send the execution pointer back up and create a loop!

- JMP uses its A (Left Address) as the jump destination. - A negative offset ($-1) means "jump 1 line UP (back to 0000)"!

🎯 Your Task Change the highlighted A (Left Address) of JMP on row 0001 from $0 to $-1 (click the - button once), then press [PLAY] to keep the loop running for 10+ cycles!

1. Defying Gravity: How JMP Hijacks the Program Counter

From Step 1 through Step 11, the Program Counter (PC) behaved like a stone pulled by gravity: on every clock cycle, it fell strictly downward one row at a time (0000 ➔ 0001 ➔ 0002...) until it inevitably crashed into a DAT cell and died.

If a computer could only execute instructions in a straight line from top to bottom, performing a million calculations would require writing a million lines of code. What liberated computers from this limitation—and gave digital organisms eternal life—is the instruction you mastered in Step 12: "JMP" (Unconditional Jump).

Whereas ADD and MOV mutate data boxes inside RAM, JMP does not alter memory cells at all. Instead, JMP reaches directly into the processor itself and overwrites the Program Counter (PC), redirecting the flow of time to a new address! In CPU microarchitecture, while arithmetic instructions route their output back to the data bus or register file, a jump instruction routes its Effective Address output directly into the Program Counter's input latch, overriding the normal "+1" sequential incrementer.

[0000] ADD.AB #1, $2  ◄──┐ (Cycle 1, 3, 5, 7, 9...)
         │               │
         ▼               │JMP.A $-1 (Rewrites PC = 0001 - 1 = 0000!)
[0001] JMP.A $-1, #0  ───┘ (Cycle 2, 4, 6, 8, 10...)
[0002] DAT.F  #0, #0       (Never stepped on! Safe below the loop)

2. Negative Relative Offsets ($-1) and the Birth of the Loop

In this mission, you changed the A-field (jump destination) of "JMP.A $0, #0" on row 0001 to "$-1". - When the operand was "$0", the jump target was 0001 + 0 = 0001, trapping the execution pointer on line 2 forever without doing any useful work. - When you changed the operand to "$-1", the jump target became 0001 - 1 = 0000 (one row UP).

Look at the resulting execution trace: - Cycle 1: Execute "ADD.AB #1, $2" at 0000; PC advances naturally to 0001. - Cycle 2: Execute "JMP.A $-1, #0" at 0001; PC is rewritten back to 0000! - Cycle 3: Execute "ADD.AB #1, $2" at 0000 a second time!

A program that occupies only two lines of physical space has now achieved infinite extent in time. Safely bouncing above the lethal DAT cell at 0002, this two-line loop can run for 10 cycles, 1,000 cycles, or forever. Notice the profound relationship between spatial footprint and temporal longevity: before Step 12, surviving for N cycles required N lines of code (a 1:1 ratio of space to time). With a single backward JMP instruction, two lines of space generate an infinite number of execution cycles, decoupling a program's lifespan from its physical size in memory.

3. The Structured Program Theorem and the Heartbeat of Living Code

In 1966, computer scientists Corrado Böhm and Giuseppe Jacopini proved the foundational Structured Program Theorem, demonstrating that any computable algorithm in the universe can be constructed from just three control structures: (1) Sequence (stepping line by line), (2) Iteration (looping via jumps), and (3) Selection (conditional branching).

While beginning programmers in standard software development are often warned to avoid "infinite loops", in systems engineering and artificial life the truth is the exact opposite. An operating system kernel, a video game engine, a heart pacemaker, and a CoreWar organism must NEVER exit their main loop—because exiting the loop means death. The JMP loop you just built is the literal heartbeat that keeps a digital organism alive. Inside a real microprocessor, backwards jump instructions (branches with a negative offset) are so common that hardware branch predictors specifically assume any backward jump is the bottom of a loop and speculatively pre-fetch the top of the loop before the jump even finishes executing! By mastering "JMP.A $-1", you have harnessed the fundamental temporal engine of computation.

🔒

🔒 MISSION CLEAR Unlocks the Full Lecture Note

Complete the experiment in the simulator above to automatically unlock the full deep-dive article—or click below to read the full text immediately.