COREWAR

/
Step 15: Copying Your Own Instruction (Code = Data)
🎯Copy the MOV instruction into Cell 0001(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
TASKS: 0
CYC: 0
📖 LECTURE NOTE // STEP 15 OF 30Chapter 3: Von Neumann Awakening & Digital Life⏱ 5 min read
📖 Lecture Note: Computer Science & Artificial Life Principles Behind This Experiment

The Equivalence of Code and Data: Self-Reference and Metaprogramming

How an instruction can read its own memory address ($0) as data and clone itself into a new location

#Code = Data (Homoiconicity)#Self-Reference ($0)#Self-Modifying Code#Quine#Instruction Cloning
🔬Step 15: Copying Your Own Instruction (Code = Data)

Because instructions and data live in identical memory boxes, a MOV instruction can copy an instruction itself as data into another box!

Right now, 0000 says MOV.I $1, $1 (copy 1 row down to 1 row down). What if you change the source address (A) from $1 to $0 (0 rows away = this very MOV instruction at 0000 itself!)?

🎯 Your Task Change the highlighted A (Left Address) of 0000 from $1 to $0 and press [STEP] once to watch the MOV instruction copy itself into Cell 0001!

1. Referencing "$0": Looking in the Mirror

In Step 14, we witnessed the destructive side of Von Neumann architecture: when data is treated as an instruction, the processor crashes. Here in Step 15, we flip the coin to witness its miraculous creative side: when an instruction is treated as data, a program can read and replicate itself!

Consider what happened when you changed the source address (A-field) of "MOV.I $1, $1" at Address 0000 from "$1" to "$0". In PC-relative addressing, "$1" means 1 row down, and "$-1" means 1 row up. What, then, does "$0" (zero rows away) mean? It points directly to Address 0000 itself—the very cell currently being executed!

When you pressed [STEP], the instruction "MOV.I $0, $1" reached into its own memory box ($0), read its own complete instruction word ("MOV.I $0, $1") as if it were ordinary data, and wrote an exact clone of itself into the box one row below ($1 = Address 0001), overwriting the old DAT cell!

[0000] MOV.I $0, $1  ──┐ (1. Reads its own cell $0 = "MOV.I $0, $1")
         ▲             │
         └───($0)──────┤
                       ▼ (2. Writes clone into $1 = [0001])
[0001] MOV.I $0, $1  ◄─┘ (Cell 0001 is now an identical executable instruction!)

2. What Does "Code Is Data" Truly Mean?

When learning high-level programming languages like Python, Java, or C, we are taught to think of "source code" (functions and statements) and "data" (numbers and strings) as two completely separate realms. You rarely see a C function reach into RAM to read its own compiled machine bytes and copy them elsewhere.

At the physical level of the CPU and RAM, however, there is zero structural difference between an instruction like "MOV.I $0, $1" and a data cell like "DAT.F #0, #99". Both are simply structured words sitting in memory slots: - When the Program Counter (PC) points to a cell, that cell acts as CODE (an instruction to be decoded and executed). - When an operand (like $0 or $1 in a MOV or ADD) points to that exact same cell, the cell acts as DATA (material to be read or modified).

Whether a memory box is "code" or "data" is not an intrinsic property of the box—it depends entirely on how the processor interacts with it at that microsecond. Computer scientists call this profound duality Code-Data Equivalence (or Homoiconicity).

3. From Self-Modifying Code to Modern JIT Compilers

A program that generates, copies, or alters executable instructions at runtime is practicing Self-Modifying Code and Metaprogramming (programs that write programs).

Far from being an esoteric trick, runtime code generation powers the very web browser you are using right now. Inside modern JavaScript and WebAssembly engines (like V8 in Chrome or JavaScriptCore in Safari), a Just-In-Time (JIT) compiler translates scripts into raw machine instructions on the fly, writes those instructions as data into a memory buffer, and then points the CPU's Program Counter at that buffer to execute the newly minted code at native speed.

Look closely at the workbench right now: at the end of Step 15, a fresh copy of "MOV.I $0, $1" sits at Address 0001, and the glowing Program Counter has just stepped onto Address 0001! In computer science, a program that takes no external input and outputs an exact copy of its own source code is called a "Quine" (named after philosopher and logician Willard Van Orman Quine, who studied paradoxes of self-reference). In high-level languages like C or Python, writing a Quine requires clever string formatting tricks; in the Von Neumann memory of CoreWar, however, "MOV.I $0, $1" is an effortless hardware-level Quine in a single instruction word! What will happen if we keep pressing [STEP]? Turn to Step 16 to witness the birth of artificial life.

🔒

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