COREWAR

/
SUB - Subtract
🎯Press [STEP] 3 times to observe the value at 0002 being decremented(0/3)
🟢 EDIT MODE (Click cells to modify)
[Addr][Opcode][A (Left)][B (Right)]
📦 DATA / BOMB (DAT)
+2
0000
-SUB
#
$
0001
↺JMP
$
0002
■DAT
#
#
◎ B-TARGET
0003
■DAT
$0
$0
++ ADD ROW
0004
■DAT
$0
$0
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 (4/19)

SUB - Subtract

SUB: Subtract

SUB calculates B - A and stores the result in B. It is the counterpart of ADD and equally important for pointer manipulation.

Syntax

SUB A, B   ; B = B - A

Common Uses

Reverse Scanning

While ADD scans forward, SUB allows scanning backward through memory:

scan: SUB #5, ptr    ; Move pointer backward
      JMZ scan, @ptr ; Skip empty cells
      MOV bomb, @ptr ; Attack!
      JMP scan
ptr:  DAT 0, 0
bomb: DAT 0, 0

Counter Logic

Decrement a counter for timed operations:

SUB #1, count
JMN loop, count  ; Continue while count > 0

Modifiers

  • .A — Subtract A-fields only
  • .B — Subtract B-fields only (default)
  • .AB — Subtract source A from destination B
  • .F — Subtract both fields independently

Strategic Notes

SUB is less common than ADD in competitive warriors but is essential for certain scanning patterns and countdown mechanisms.

📚 REDCODE-94 INSTRUCTION REFERENCE (4/19)

SUB - Subtract

SUB: Subtract

SUB calculates B - A and stores the result in B. It is the counterpart of ADD and equally important for pointer manipulation.

Syntax

SUB A, B   ; B = B - A

Common Uses

Reverse Scanning

While ADD scans forward, SUB allows scanning backward through memory:

scan: SUB #5, ptr    ; Move pointer backward
      JMZ scan, @ptr ; Skip empty cells
      MOV bomb, @ptr ; Attack!
      JMP scan
ptr:  DAT 0, 0
bomb: DAT 0, 0

Counter Logic

Decrement a counter for timed operations:

SUB #1, count
JMN loop, count  ; Continue while count > 0

Modifiers

  • .A — Subtract A-fields only
  • .B — Subtract B-fields only (default)
  • .AB — Subtract source A from destination B
  • .F — Subtract both fields independently

Strategic Notes

SUB is less common than ADD in competitive warriors but is essential for certain scanning patterns and countdown mechanisms.