Djnz — Decrement And Jump If Non-Zero - Samsung S3F84B8 User Manual

8-bit cmos
Hide thumbs Also See for S3F84B8:
Table of Contents

Advertisement

S3F84B8_UM_REV 1.00
6.3.26 DJNZ — DECREMENT AND JUMP IF NON-ZERO
r,dst
DJNZ
r  r – 1
Operation:
If r  0, PC  PC + dst
The working register, which is used as a counter, is decremented. If the contents of register are
not logic zero after decrementing, the relative address is added to the program counter and
control is passed to the statement whose address is now in the PC. The range of the relative
address is +127 to –128, and the original value of the PC is taken as the address of instruction
byte following the DJNZ statement.
While using the DJNZ instruction, the working register (which is used as a counter) should be set at the one
NOTE:
of the locations 0C0H to 0CFH with SRP, SRP0, or SRP1 instruction.
No flags are affected.
Flags:
Format:
r | opc
Given R1 = 02H and LOOP is the label of a relative address:
Example:
SRP
DJNZ R1,LOOP
DJNZ controls a "loop" of instructions. In many cases, a label is used as the destination operand
instead of a numeric relative address value. In the example, working register R1 contains the
value 02H, and LOOP specifies the label for a relative address.
The statement "DJNZ R1, LOOP" decrements register R1 by one, leaving the value 01H. Since
the contents of R1 after the decrement are non-zero, the jump is taken to the relative address
specified by the LOOP label.
dst
#0C0H
Bytes
Cycles
2
8 (jump taken)
8 (no jump)
6-38
6 INSTRUCTION SET
Opcode
Addr Mode
(Hex)
dst
rA
RA
r = 0 to F

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents