
DJNZ Instruction UM018809-0611
100
ZNEO
®
CPU Core
User Manual
DJNZ
Definition
Decrement and Jump if Non-Zero
Syntax
DJNZ dst, urel4
Operation
dst dst
– 1
if dst
0 {
PC PC + {FFFF_FFH, 111B, urel4, 0B}
}
Description
This instruction decrements the destination register and then performs a conditional jump if the
result is nonzero. Otherwise, the instruction following the DJNZ instruction is executed.
In assembly language, the jump destination is typically specified as a label or 32-bit address
operand. The ZNEO CPU assembler automatically calculates a relative offset and generates the
appropriate DJNZ opcode. The jump destination address is the PC value plus the calculated off-
set.
In object code, the offset operand is a 4-bit unsigned value corresponding to bits [4:1] of a nega-
tive PC offset. In practical terms, if urel4=0, the offset is –16 words. If urel4=FH, the offset is –1
word. The offset is measured from the instruction following DJNZ.
Flags
76543210
C Z S V B CIRQE IRQE
*****–––
Legend
C = Set to 1 if the result generated a borrow; otherwise set to 0.
Z = Set to 1 if the result is zero; otherwise, set to 0.
S = Set to 1 if the result msb is 1; otherwise set to 0.
V = Set to 1 if an arithmetic overflow occurs; otherwise set to 0.
B = Set to 1 if the initial destination value was 0; otherwise set to 0.
CIRQE = No change.
IRQE = No change.
Comentarios a estos manuales