📚 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