COREWAR

/
Step 4: The Three Rooms of a Memory Box (Changing B)
🎯Set Cell 0000 B-value (right value) to 5(0/5)

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
TASKS: 0
CYC: 0
📖 LECTURE NOTE // STEP 04 OF 30Chapter 1: UI Controls & Memory Architecture⏱ 5 min read
📖 Lecture Note: Computer Science & Artificial Life Principles Behind This Experiment

Anatomy of a Machine Instruction Word: Opcode, A-Field, and B-Field

Why every memory cell is divided into three distinct rooms, and how fixed-length instruction words simplify CPU hardware design

#Instruction Word Format#Opcode#A-Field & B-Field#Fixed-Length Instruction#ICWS-94 Standard
🔬Step 4: The Three Rooms of a Memory Box (Changing B)

Look at the column headers at the top of the memory view. Every single memory row in CoreWar is divided into three rooms: 1. [Opcode]: What action to perform (DAT, ADD, MOV, etc.) 2. [A (Left Value)]: The left-hand number (A-field) 3. [B (Right Value)]: The right-hand number (B-field)

The B (Right Value) room is most commonly used to store data values.

🎯 Your Task Change ONLY the B (Right Value) of DAT #0, #0 at Address 0000 to 5, then press [STEP]!

1. Every Memory Row Is a Structured Machine Word

In Step 4, you explored the internal layout of a single memory cell—divided into three distinct rooms: Opcode, A (Left Value), and B (Right Value)—and set the B-field of Address 0000 to 5.

Beginners encountering assembly language for the first time often wonder: "Why is memory rigidly partitioned into these specific slots instead of letting us write free-form text like a normal document?"

The answer lies in the physical nature of digital hardware. While a human brain can parse flexible sentences of varying lengths, a CPU's instruction decoder is built from physical logic gates and wires. If every memory cell follows a strict, uniform blueprint—Slot 1 for the operation type (Opcode), Slot 2 for the first operand (A-field), and Slot 3 for the second operand (B-field)—the hardware can route each piece of information directly into the Arithmetic Logic Unit (ALU) in a single clock cycle without wasting time guessing where one piece of data ends and another begins.

┌─────────────────────────────────────────────────────────────┐
│             1 Memory Cell (ICWS-94 Instruction Word)        │
├───────────────────┬────────────────────┬────────────────────┤
│  Room 1: OPCODE   │   Room 2: A-FIELD  │   Room 3: B-FIELD  │
│  (Action + Mod)   │  (Mode + A-Value)  │  (Mode + B-Value)  │
│      DAT.F        │        #0          │        #5          │
└───────────────────┴────────────────────┴────────────────────┘

2. RISC Architecture and the Elegance of Fixed-Length Words

In the history of computer architecture, two major design philosophies have competed for dominance. The first is CISC (Complex Instruction Set Computer), exemplified by Intel's x86 architecture, where instructions vary wildly in length from 1 byte to 15 bytes. The second is RISC (Reduced Instruction Set Computer), which powers ARM processors, Apple Silicon, and RISC-V. In a classic RISC design, every single instruction occupies the exact same fixed width (typically one 32-bit word).

CoreWar's virtual machine (MARS, governed by the ICWS-94 standard) is the ultimate expression of fixed-length architectural purity. In CoreWar, every memory address—from 0000 to 0799—holds exactly one complete instruction word consisting of an Opcode (with its modifier), an A-operand, and a B-operand.

Because every instruction and every data item occupies the exact same unit of space (one cell), the Program Counter never has to calculate variable byte offsets to find the next instruction—it simply increments by 1. Even more importantly, a single MOV instruction can copy any instruction in the universe in one atomic step. If instructions had variable byte lengths like x86, copying an instruction or jumping backward would require counting exact byte boundaries, and jumping into the middle of a multi-byte instruction would corrupt the instruction stream. Uniform 1-cell words make self-replication and pointer math clean and predictable.

3. Why the B-Field (Right Room) Is the Primary Data Slot

In this exercise, we specifically stored the number 5 inside the B-field (the right-hand room) rather than the A-field. Throughout CoreWar and the Redcode-94 standard, there is a universal convention: when a DAT cell is used to hold a single numerical variable, counter, or pointer offset, that number is stored in the B-field.

Why the B-field instead of the A-field? As you will discover in upcoming steps, standard arithmetic instructions (like ADD.AB) and indirect pointer modes (like @ and <) are hardwired by default to treat the A-field as the incoming source value and the B-field of the target cell as the destination accumulator or pointer address. By keeping your primary data in the right-hand room (B), all standard Redcode instructions naturally align with your data boxes. This convention also makes inspecting memory during debugging much faster: whenever your eyes scan down the rightmost column of the workbench or the Memory Inspector, you are looking directly at the active counters, bomb payloads, and target pointers of the program. Building this habit early will make dissecting complex warriors effortless.

🔒

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