📚 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 != 0Classic 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, 0Imp Spiral
DJN can create an Imp Spiral that distributes processes across memory:
SPL 2
SPL 1
DJN 0, #0 ; Creates processes that spreadKey Difference from JMN
JMNonly tests — it does not modify the valueDJNboth decrements AND tests in a single instruction- This makes
DJNideal 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.