Keil Logo

DJNZ

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.

See Also: CJNE

DJNZ direct, offset
C AC F0 RS1 RS0 OV   P
Bytes 3
Cycles 2
Encoding
11010101 direct offset
Operation
DJNZ
PC = PC + 2
(direct) = (direct) - 1
IF (direct) <> 0
  PC = PC + offset
Example
DJNZ 40h, LABEL
DJNZ Rn, offset
C AC F0 RS1 RS0 OV   P
Bytes 2
Cycles 2
Encoding
11011nnn offset
Operation
DJNZ
PC = PC + 2
Rn = Rn - 1
IF Rn <> 0
  PC = PC + offset
Example
DJNZ R6, LABEL
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.