📚 REDCODE-94 INSTRUCTION REFERENCE (7/19)
MOD - Modulo
MOD: Modulo (Remainder)
MOD calculates the remainder of B / A and stores it in B. Like DIV, division by zero terminates the process.
Syntax
MOD A, B ; B = B % AUse Cases
Wrapping Values
Keep pointer values within a specific range:
MOD #100, ptr ; Ensure ptr stays within 0-99Pattern Generation
Create repeating bombing patterns:
loop: ADD #7, ptr
MOD #100, ptr ; Wrap within 100-cell range
MOV bomb, @ptr
JMP loop
ptr: DAT 0, 0
bomb: DAT 0, 0Modifiers
.A— Modulo A-fields.B— Modulo B-fields (default).F— Modulo both fields independently
Strategic Notes
MOD is useful for creating warriors that bomb in specific patterns within bounded regions. Combined with prime numbers, it can create efficient core-coverage strategies.