COREWAR

/
Step 24: Stopping an Imp with a Pre-Decrement "Imp-Gate"
🎯Destroy the enemy Imp using pre-decrement (<)(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
#
$
👈 EDIT
0001
▼MOV
<
<
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
P1: 0
P2: 0
CYC: 0
📖 LECTURE NOTE // STEP 24 OF 30Chapter 4: Warrior Dissection, Multitasking & Sensors⏱ 5 min read
📖 Lecture Note: Computer Science & Artificial Life Principles Behind This Experiment

Atomic Pre-Decrement ("<") and Defensive Engineering: The Imp-Gate

How the "<" addressing mode combines pointer subtraction and memory writing into a single atomic cycle to crush advancing Imps

#Pre-Decrement Indirect (<)#Atomic Operation#Imp-Gate Defense#Relative Velocity#Compound Addressing
🔬Step 24: Stopping an Imp with a Pre-Decrement "Imp-Gate"

An enemy Imp (MOV $0, $1) is marching toward you 1 cell at a time! A regular Dwarf that bombs every 4 cells will let the tiny 1-cell Imp slip right through the gaps.

To crush an Imp, use the < (Pre-Decrement Indirect) addressing mode, which automatically subtracts 1 from the pointer's B-value before every access! By changing the B-mode of MOV.I $2, $2 on row 0000 from $ to < (MOV.I $2, <2), your warrior sweeps backward from 415 without leaving any gaps, slamming a wall of DAT bombs directly into the advancing Imp!

🎯 Your Task Change the highlighted B-Mode ($) on row 0000 to <, then press [PLAY] to crush the enemy Imp!

1. The Bomber's Nightmare: Why Standard Dwarf Struggles Against an Imp

Concluding Chapter 4, Step 24 pitted you against an advancing enemy Imp ("MOV.I $0, $1") marching steadily forward from Address 0400. By changing the B-field addressing mode on row 0000 from "

quot; to "<" (Pre-Decrement Indirect), you erected an impenetrable wall of DAT bombs that crushed the Imp in its tracks.

Why is the humble 1-line Imp such a frustrating opponent for standard bombers like Dwarf? First, an Imp's active body is only 1 cell wide, and it moves forward every single turn. A Dwarf firing every 4 cells has a high probability of jumping right over the Imp's head. Second, even if Dwarf's bombs hit the trail of old "MOV.I $0, $1" copies behind the Imp, destroying those old copies does nothing—because the Imp's execution pointer has already moved ahead!

To kill an Imp, a defender must land a DAT bomb directly onto the exact cell where the Imp's execution pointer currently stands—or lay down a continuous, gap-free barrage moving backward into the oncoming Imp.

Advancing Imp  : [0400] ──► [0401] ──► [0402] ──► [0403] (Moves +1 per turn)
"<" Imp-Gate   : [0415] ◄── [0416] ◄── [0417] ◄── [0418] (Sweeps -1 per loop with zero gaps!)
                                  💥 Head-on Collision Guaranteed!

2. Two Actions in One Clock Cycle: How "<" (Pre-Decrement) Works

Normally, moving a pointer and firing a bomb requires two separate instructions: an "ADD/SUB" line to update the pointer, and a "MOV @" line to fire the bomb (taking 3 cycles per shot including the JMP). The "<" addressing mode—known in computer architecture as Pre-Decrement Indirect Addressing—combines pointer subtraction and indirect memory access into a single atomic clock cycle!

Let's trace what happens inside the MARS processor during the single cycle when "MOV.I $2, <2" executes at Address 0000: 1. LOOKUP: The CPU locates the pointer cell 2 rows down at Address 0002 ("DAT.F #0, #415"). 2. PRE-DECREMENT: Before computing the target address, the hardware automatically subtracts 1 from Cell 0002's B-field in place, mutating it from 415 to 414! 3. DEREFERENCE & WRITE: Immediately within the same clock cycle, the CPU uses the newly decremented pointer value (0002 + 414 = Address 0416) as the destination address and drops the DAT bomb there!

Because "<" updates the pointer for free inside the MOV instruction itself, your loop shrinks to just 2 lines (MOV and JMP), firing a continuous wall of DAT bombs backward (0416 ➔ 0415 ➔ 0414 ➔ 0413...) every 2 cycles without a single gap!

3. The Physics of Head-On Collision and the "Imp-Gate"

Why is sweeping the pointer backward ("-1" via "<") so devastatingly effective against an Imp? Think of the physics of relative velocity. The enemy Imp starts at 0400 and marches forward (+1 address per turn: 0400 ➔ 0401 ➔ 0402...). Meanwhile, your "<" bomber starts just ahead of the Imp at 0416 and sweeps backward (-1 address every 2 turns: 0416 ➔ 0415 ➔ 0414...).

Because the Imp is moving in the positive direction (+1) while your gap-free wall of DAT bombs is moving in the negative direction (-1), the two trajectories are on an inescapable head-on collision course! Neither can slip past the other without occupying the exact same integer coordinate, guaranteeing the Imp's destruction.

In advanced CoreWar engineering, a tight loop that continuously decrements a memory cell using "<" is called an Imp-Gate: an automated defensive turnstile that shreds any Imp attempting to crawl through that sector of memory. Moreover, as you will see in Chapter 5, this exact "<" mode (equivalent to "*(--ptr)" in C) is also the secret engine behind high-speed self-replication!

🔒

🔒 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.