You are here : assembly8051DJNZ

DJNZ - 8051

The DJNZ instruction decrements the byte indicated by the first operand and, if the resulting value is not zero, branches to the address specified in the second operand.

NOTE : When this instruction is used to modify an output port, the value used as the port data is read from the output data latch, not the input pins of the port.


Syntax

DJNZ direct,offset	;3 bytes 2 cycles
DJNZ Rn,offset		;2 bytes 2 cycles


Example

;DJNZ Operation
;PC = PC + 2
;(direct) = (direct) - 1
;IF (direct) <> 0
;  PC = PC + offset

DJNZ 40h, LABEL

;DJNZ Operation
;PC = PC + 2
;Rn = Rn - 1
;IF Rn <> 0
;  PC = PC + offset

DJNZ R6, LABEL


Output / Return Value


Limitations


Alternatives / See Also


Reference