The Science of Indirect Addressing (@ Pointers): How Static Code Gains Dynamic Reach
Two-stage address dereferencing: how treating a data cell's number as a destination address unlocks the entire memory space
To finish Chapter 3, let's learn the secret weapon behind bombers: @ (B-Field Indirect Addressing / Pointers)! - $ goes directly to the relative address written in the instruction. - @ is a two-step lookup: "Go to the specified data box first, read its B-value as a destination memo, and launch the data there!"
Right now, 0000 says MOV.I $2, @2, using Cell 0002 as its pointer box (watch the dashed purple arrow!).
🎯 Your Task Change the highlighted B (Right Value) of the pointer box at Address 0002 from 0 to 3 (which points 3 cells ahead of 0002 to 0005) or 5, watch the purple arrow extend, and press [STEP]!
1. The Limitation of Direct Addressing ($): Why Fixed Offsets Aren't Enough
Capping off Chapter 3, Step 18 demystifies one of the most powerful concepts in all of computer science—a concept infamous for challenging students in C and assembly courses, yet crystal clear when seen visually in CoreWar: Pointers (Indirect Addressing via the "@" symbol).
First, consider why Direct Addressing ("
quot;) alone is not enough to build a real warrior. In Step 17, "MOV.I $0, $4" always wrote to Address 0004. Even if you loop that instruction a thousand times, it will hammer Address 0004 a thousand times while leaving the other 799 cells of the Arena completely untouched! If you only had "quot;, sweeping an 800-cell arena would require writing 800 separate MOV instructions.How can a compact 3-line or 4-line program fire at Address 0005 on loop 1, Address 0009 on loop 2, and Address 0013 on loop 3 using the exact same MOV line? The answer is Indirect Addressing ("@").
Direct ($2) : [0000] MOV $2, $2 ──► Writes directly into Cell [0002] (Fixed target)
Indirect (@2) : [0000] MOV $2, @2 ──(Step 1: Look at pointer box [0002])──┐
[0001] JMP $-1, #0 │
[0002] DAT #0, #3 ◄───────────────────────────────────────┘
│
└────(Step 2: Read B-value "+3", jump 3 rows from [0002])
▼
[0005] DAT #0, #3 ◄──💥 Final Landing Address = 0002 + 3 = 0005!2. The Two-Stage Rocket: How "@" (B-Indirect Dereferencing) Works
Let's compare "$2" and "@2" using the analogy of delivering a package: - Direct Addressing ("$2"): "Deliver this package to the house 2 doors down (Address 0002)." The courier drops the package at 0002 and is done. - Indirect Addressing ("@2"): "Go to the house 2 doors down (Address 0002) and read the forwarding number written on its B-field signboard. Then carry the package that many doors further down from Address 0002!"
Let's trace your exact experiment when Row 0000 is "MOV.I $2, @2" and Row 0002 is "DAT.F #0, #3": 1. STAGE 1 (Pointer Lookup): To resolve "@2", the CPU first travels 2 rows down from 0000 to inspect the pointer box at Address 0002. 2. STAGE 2 (Dereferencing): The CPU reads the B-value stored inside Address 0002, which you set to 3. Using the pointer box itself (Address 0002) as the base, the CPU adds +3 to compute the final Effective Address: 0002 + 3 = Address 0005!
Notice the magic here: without touching the MOV instruction at Address 0000 at all, simply changing the data number inside Address 0002 from 0 to 3 (or 5) redirected the purple target beam across space to strike Address 0005 (or 0007)!
3. Connecting C Pointers (*ptr) to the Birth of the Bomber
In computer science and languages like C, C++, and Rust, a memory cell (like Address 0002) that holds the address offset of another cell is called a Pointer Variable, and following that pointer to its final target via "@" is called Dereferencing (written as "*ptr" in C). When a C compiler translates "*ptr = val;" into machine code, it emits the exact indirect addressing instruction you just executed in Step 18.
Now, put the two halves of your knowledge together! - In Step 13 (end of Chapter 2), you built an Automatic Counter that used "ADD" inside a "JMP" loop to automatically increase a DAT cell's B-value every cycle. - In Step 18 (end of Chapter 3), you learned that "@2" launches a bomb to whatever address is written inside that DAT cell's B-value.
What happens when you combine the Automatic Counter with the "@" Pointer? On every turn of the loop, the pointer number increases automatically—and the "@" instruction fires a DAT bomb to a brand-new address across the Arena! Turn to Chapter 4 (Step 19) to see this exact synthesis come alive as the legendary "Dwarf" bomber.
🔒 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.