![]() |
|
| << Previous | Next >> | |
| | |
DJNZ label Decrement and Jump if Not Zero Rabbit 2000/3000/4000/5000 Instruction
10 e DJNZ label
DJNZ mn1B = B - 1
if {B != 0} then PC = PC2 + e
1 The 16-bit constant mn is the destination logical address of the jump.
2 The value of PC after the instruction fetch.
Rabbit 2000/3000/4000 Rabbit 5000
Description
This instruction controls program flow by allowing conditional jumps to specified locations.
First, B is decremented. If B does not equal zero, the instruction transfers control to the specified address. The address is specified by a label or logical address. The assembler translates the label or logical address "mn" to an 8-bit signed displacement value "e".
The displacement value "e" is relative to the address of the first byte of the instruction following DJNZ. This fact is because the processor calculates the new PC value after it increments the PC for the instruction fetch of DJNZ.
If B does equal zero, PC is incremented normally.
Note that the relative jump has a limited range of [-128, 127] from the address of the first byte of the instruction following the DJNZ instruction.
| Rabbit Instructions | << Previous | Next >> | rabbit.com |