The Minimal Autonomous Program: State Machines and Digital Homeostasis
How the trinity of Computation (ADD), Control (JMP), and Memory (DAT) forms a self-sustaining automaton
To complete Chapter 2, let's finish building an Automatic Counter! 1. 0000: ADD.AB #1, $2 (Add 1 to the data box 2 rows down at 0002) 2. 0001: JMP.A $-1, #0 (Jump 1 row up back to 0000) 3. 0002: DAT.F #0, #0 (The counter data box)
Right now, row 0000 adds #0, so the counter doesn't increase.
🎯 Your Task Change the A (Left Value) of 0000 from #0 to #1 (or higher), press [PLAY], and watch Cell 0002's B-value count up to 5 or more!
1. The Trinity of Computing: Operation, Control, and Storage
To complete Chapter 2, Step 13 brought together everything you have learned into a self-sustaining three-line program—an Automatic Counter: - Row 0000: "ADD.AB #1, $2" ➔ COMPUTATION (the active force that transforms state) - Row 0001: "JMP.A $-1, #0" ➔ CONTROL (the feedback loop that sustains execution across time) - Row 0002: "DAT.F #0, #0" ➔ STORAGE (the memory vessel that accumulates state)
Pause and admire these three lines. What you have built here is not merely a toy exercise—it is the irreducible archetype of every computer program ever written, from operating systems and database engines to modern artificial intelligence.
Consider what happens if any single pillar of this trinity is removed: - Without Row 0000 (Computation), the loop spins forever in place without ever changing the world. - Without Row 0001 (Control), the program adds 1 once and immediately falls into Row 0002 and dies. - Without Row 0002 (Storage), there is no state variable to remember the progress made by previous iterations. Only when Computation, Control, and Storage interlock does a static list of instructions awaken as a dynamic, evolving process.
┌─────────────────── THE COMPUTATIONAL TRINITY ───────────────────┐
│ [0000] ADD.AB #1, $2 ──► 1. COMPUTATION (ALU updates state) ─┼─┐
│ [0001] JMP.A $-1, #0 ──► 2. CONTROL (Loop sustains life) │ │
│ [0002] DAT.F #0, #5 ◄── 3. STORAGE (Memory holds 1,2,3..)◄┘ │
└─────────────────────────────────────────────────────────────────┘2. The Two-Cycle Metabolic Rhythm and Digital Homeostasis
When you pressed [PLAY] and watched Cell 0002 count upward (1, 2, 3, 4, 5...), you may have noticed a distinct rhythm: the counter increments once every TWO clock cycles. - On odd cycles (Cycle 1, 3, 5, 7, 9), the processor executes "ADD" at 0000, increasing the counter by 1. - On even cycles (Cycle 2, 4, 6, 8, 10), the processor executes "JMP" at 0001, returning the Program Counter to the top of the loop.
In biology, the ability of a living system to maintain a stable, self-regulating internal cycle is called Homeostasis. Your three-line automaton exhibits a two-cycle metabolic heartbeat: one beat to act upon memory, and one beat to reset its posture for the next action.
Notice also the dramatic transformation in the role of "DAT" at Address 0002. In earlier steps, a DAT cell was a lethal hazard waiting to kill our falling execution pointer. Now, because the JMP instruction on line 2 creates a protective boundary that turns the execution pointer back before it can ever touch line 3, that very same DAT cell is safely harnessed as an internal organ—a memory register storing our growing counter.
3. How a Simple Counter Evolves into a Bomber or Scanner
At this point, you might wonder: "Counting 1, 2, 3, 4, 5 inside box 0002 is neat, but how does a simple counter become a combat warrior?"
Imagine taking that exact number counting up inside Address 0002 (1, 2, 3, 4, 5...) and treating it not as a passive score, but as a target address coordinate (a Pointer)! On the first loop, your program fires at Address +1; on the second loop, it automatically fires at Address +2; on the third loop, Address +3—sweeping across the entire memory arena automatically without any human intervention!
The humble three-line counter you built in Step 13 is, in fact, the exact engine that powers every bomber (Dwarf), every scanner (Scissors), and every replicator (Paper) in CoreWar. In theoretical computer science, an automaton equipped with unbounded counters that can be incremented, decremented, and tested is known as a Minsky Register Machine (or Counter Machine)—a mathematical model proven by Marvin Minsky in 1961 to be Turing-complete, meaning it can compute anything that the most powerful supercomputer on Earth can compute! In Chapter 3, we will unlock the Von Neumann secrets that turn this counter into a true digital organism.
🔒 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.