Intel 8XC251SA User Manual page 310

Embedded microcontroller
Hide thumbs Also See for 8XC251SA:
Table of Contents

Advertisement

8XC251SA, SB, SP, SQ USER'S MANUAL
Example:
The on-chip RAM locations 40H, 50H, and 60H contain 01H, 70H, and 15H, respectively.
After executing the following instruction sequence
DJNZ 40H,LABEL1
DJNZ 50H,LABEL2
DJNZ 60H,LABEL
on-chip RAM locations 40H, 50H, and 60H contain 00H, 6FH, and 14H, respectively, and
program execution continues at label LABEL2. (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:
toggles P1.7 eight times, causing four output pulses to appear at bit 7 of output Port 1. Each
pulse lasts three states: two for DJNZ and one to alter the pin.
Variations
DJNZ dir8,rel
Not Taken
Bytes:
3
States:
3
[Encoding]
1 1 0 1
Hex Code in:
Binary Mode = [Encoding]
Source Mode = [Encoding]
Operation:
DJNZ
(PC) ← (PC) + 2
(dir8) ← (dir8) – 1
IF (dir8) > 0 or (dir8) < 0
DJNZ Rn,rel
Not Taken
Bytes:
2
States:
2
[Encoding]
1 1 0 1
Hex Code in:
Binary Mode = [Encoding]
Source Mode = [A5][Encoding]
A-58
MOV R2,#8
CPL P1.7
DJNZ R2,TOGGLE
Binary Mode
Taken
3
6
0 1 0 1
THEN
(PC) ← (PC) + rel
Binary Mode
Taken
2
5
1 r r r
Source Mode
Not Taken
Taken
3
3
direct addr
rel. addr
Source Mode
Not Taken
Taken
3
3
rel. addr
3
6
3
6

Advertisement

Table of Contents
loading

This manual is also suitable for:

8xc251sb8xc251sp8xc251sq

Table of Contents