Keil Logo

Ax51 Introduction DJNZ

Decrement and jump if not zero

Description  

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_Address, relative_offset
C AC F0 RS1 RS0 OV P
Bytes   3
Cycles   2
Encoding   11010101, direct, relative_offset
Operation  
DJNZ
PC = PC + 2
(direct_address) = (direct_address) - 1
IF (direct_address) <> 0
  PC = PC + relative_offset
Example  
DJNZ 40h, LABEL
DJNZ Rn, relative_offset
C AC F0 RS1 RS0 OV P
Bytes   2
Cycles   2
Encoding   11011nnn, relative_offset
Operation  
DJNZ
PC = PC + 2
Rn = Rn - 1
IF Rn <> 0
  PC = PC + relative_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.