📚 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 - ACommon 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, 0Counter Logic
Decrement a counter for timed operations:
SUB #1, count
JMN loop, count ; Continue while count > 0Modifiers
.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.