Download Print this page

Siemens SAB 80515 Series User Manual page 158

8-bit single-chip microcontroller family

Advertisement

DJNZ
<byte>, < rel-addr>
Function:
Decrement and jump if not zero
Description:
DJNZ decrements the location indicated by 1, and branches to the address
indicated by the second operand if the resulting value is not zero. An original value
of 00 H will underflow to 0FF H . No flags are affected. The branch destination would
be computed by adding the signed relative-displacement value in the last instruction
byte to the PC, after incrementing the PC to the first byte of the following instruction.
The location decremented may be a register or directly addressed byte.
Note:
When this instruction is used to modify an output port, the value used as the original
port data will be read from the output data latch, not the input pins.
Example:
Internal RAM locations 40 H , 50 H , and 60 H contain the values, 01 H , 70 H , and 15 H ,
respectively. The instruction sequence
DJNZ 40 H ,LABEL_1
DJNZ 50 H ,LABEL_2
DJNZ 60 H ,LABEL_3
will cause a jump to the instruction at label LABEL_2 with the values 00 H , 6F H , and
15 H in the three RAM locations. The first jump was not taken because the result was
zero.
This instruction provides a simple way of executing a program loop a given number
of times, or for adding a moderate time delay (from 2 to 512 machine cycles) with a
single instruction. The instruction sequence
TOGGLE: CPL
will toggle P1.7 eight times, causing four output pulses to appear at bit 7 of output
port 1. Each pulse will last three machine cycles; two for DJNZ and one to alter the
pin.
Semiconductor Group
MOV
R2, #8
P1.7
DJNZ
R2,TOGGLE
*
158
Instruction Set

Advertisement

loading

This manual is also suitable for:

Sab 80c515Sab 80c535Sab 80535Sab 80515k