beautypg.com

Djnz – Zilog Z8F0130 User Manual

Page 156

background image

eZ8

CPU Core

User Manual

UM012820-0810

DJNZ Instruction

141

DJNZ

Definition

Decrement and Jump if Non-Zero.

Syntax

DJNZ dst, RA

Operation

dst

 dst - 1

if dst

 0 {

PC

 PC + X

}

where the jump offset, X, is calculated by the eZ8 CPU assembler from
the Program Counter (PC) value and the Destination Address (DA).

Description

The Working Register used as a counter is decremented. If the contents of
the Working Register are not zero after being decremented, then the rela-
tive address is added to the Program Counter and control passes to the
statement whose address is now in the Program Counter. The range of the
relative address is +127 to –128. The original value of Program Counter is
the address of the instruction byte following the DJNZ statement. When
the specified Working Register counter reaches zero, control falls through
to the statement following the DJNZ instruction.

Flags

C

Unaffected

Z

Unaffected

S

Unaffected

V

Unaffected