COREWAR

/
STP - Store P-space
🎯Press [STEP] twice to observe STP saving 42 to P-space and reading it back(0/2)
🟢 EDIT MODE (Click cells to modify)
[Addr][Opcode][A (Left)][B (Right)]
📦 DATA / BOMB (DAT)
0000
•STP
#
#
0001
•LDP
#
$
0002
↺JMP
$
0003
■DAT
#
#
0004
■DAT
$0
$0
++ ADD ROW
0005
■DAT
$0
$0
0006
■DAT
$0
$0
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
📖REDCODE-94 INSTRUCTION REFERENCE(Drag to move)
📚 REDCODE-94 INSTRUCTION REFERENCE (19/19)

STP - Store P-space

STP: Store to P-space (Persistent Memory)

STP saves a value from operand A into the warrior's private P-space slot indexed by operand B. Paired with LDP, it allows a warrior to record state and adapt its tactics across tournament rounds.

Syntax

STP.AB #value, #slot  ; Store immediate #value into P-space[#slot]
STP.B  srcCell, slot  ; Store srcCell.B into P-space[slot.B]

How P-Space Indexing Works

  • P-space size is typically CORESIZE / 16 (500 slots for an 8,000-cell Core, or 50 slots for an 800-cell Core).
  • Slot indices wrap modulo P-space size.
  • Once a value is written with STP, it remains safely stored in P-space even if the Core cell that originally held it is later bombed by the enemy.

Example: Saving State & Restoring with LDP

STP.AB #42, #1   ; Save secret value 42 into P-space slot #1
LDP.AB #1,  $2   ; Read P-space slot #1 back into Core memory
JMP.A  $-2
DAT.F  #0,  #0   ; B-field receives 42 after LDP executes
📚 REDCODE-94 INSTRUCTION REFERENCE (19/19)

STP - Store P-space

STP: Store to P-space (Persistent Memory)

STP saves a value from operand A into the warrior's private P-space slot indexed by operand B. Paired with LDP, it allows a warrior to record state and adapt its tactics across tournament rounds.

Syntax

STP.AB #value, #slot  ; Store immediate #value into P-space[#slot]
STP.B  srcCell, slot  ; Store srcCell.B into P-space[slot.B]

How P-Space Indexing Works

  • P-space size is typically CORESIZE / 16 (500 slots for an 8,000-cell Core, or 50 slots for an 800-cell Core).
  • Slot indices wrap modulo P-space size.
  • Once a value is written with STP, it remains safely stored in P-space even if the Core cell that originally held it is later bombed by the enemy.

Example: Saving State & Restoring with LDP

STP.AB #42, #1   ; Save secret value 42 into P-space slot #1
LDP.AB #1,  $2   ; Read P-space slot #1 back into Core memory
JMP.A  $-2
DAT.F  #0,  #0   ; B-field receives 42 after LDP executes