COREWAR

/
DJN - Decrement Jump Not Zero
🎯Press [STEP] 3 times to watch the counter decrement 3→2→1→0 and exit the loop(0/3)
🟢 EDIT MODE (Click cells to modify)
[Addr][Opcode][A (Left)][B (Right)]
📦 DATA / BOMB (DAT)
+2
0000
↺DJN
$
$
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 (11/19)

DJN - Decrement Jump Not Zero

DJN: Decrement, Jump if Not Zero

DJN first decrements the B-field of address B, then jumps to address A if the result is not zero. A combined counter-and-branch instruction.

Syntax

DJN target, counter  ; counter--, jump if counter != 0

Classic Loop Counter

       MOV #10, count  ; Set counter to 10
loop:  MOV bomb, @ptr  ; Do something
       ADD #5, ptr
       DJN loop, count  ; Decrement count, loop while > 0
count: DAT 0, 0

Imp Spiral

DJN can create an Imp Spiral that distributes processes across memory:

SPL 2
SPL 1
DJN 0, #0  ; Creates processes that spread

Key Difference from JMN

  • JMN only tests — it does not modify the value
  • DJN both decrements AND tests in a single instruction
  • This makes DJN ideal for counted loops

Modifiers

  • .B — Decrement and test B-field (default)
  • .A — Decrement and test A-field

Strategic Notes

DJN is a key instruction for creating timed bombing runs and controlled loop counts. The Imp Spiral (DJN 0, #0) is a well-known competitive technique.

📚 REDCODE-94 INSTRUCTION REFERENCE (11/19)

DJN - Decrement Jump Not Zero

DJN: Decrement, Jump if Not Zero

DJN first decrements the B-field of address B, then jumps to address A if the result is not zero. A combined counter-and-branch instruction.

Syntax

DJN target, counter  ; counter--, jump if counter != 0

Classic Loop Counter

       MOV #10, count  ; Set counter to 10
loop:  MOV bomb, @ptr  ; Do something
       ADD #5, ptr
       DJN loop, count  ; Decrement count, loop while > 0
count: DAT 0, 0

Imp Spiral

DJN can create an Imp Spiral that distributes processes across memory:

SPL 2
SPL 1
DJN 0, #0  ; Creates processes that spread

Key Difference from JMN

  • JMN only tests — it does not modify the value
  • DJN both decrements AND tests in a single instruction
  • This makes DJN ideal for counted loops

Modifiers

  • .B — Decrement and test B-field (default)
  • .A — Decrement and test A-field

Strategic Notes

DJN is a key instruction for creating timed bombing runs and controlled loop counts. The Imp Spiral (DJN 0, #0) is a well-known competitive technique.