EasyManuals Logo

Intel MCS 51 User Manual

Intel MCS 51
334 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #73 background imageLoading...
Page #73 background image
in~.
MCS@-51PROGRAMMER’SGUIDE AND INSTRUCTIONSET
DJNZ <byte>, <rel-addr>
Function: DecrementandJumpif Not
=0
Description: DJNZ decrementsthe locationindicatedby 1,andbranchesto the addressindicatedby the
secondoperandif the resultingvalueis not zero. An originalvalueof OOHwillunderflowto
OFFH.No tlagsare at%cted.Thebranch destinationwouldbe computedbyaddingthe signed
relative-displacementvaluein the last instructionbyteto the PC, afterincrementingthe PC to
the first byte ofthe followinginstruction.
The locationdecreznentedmaybe a registeror directlyaddressedbyte.
Note:When
thisinstructionis used to modfi an outputport, the valueusedas the original
port data willbe readfrom the output data latch, notthe input pins.
Example: Internal RAM locations40H, 50~ and 60Hcontainthe valuesOIH,70H,and 15H,respec-
tively.The instructionsequence,
DJNZ 40H,LABEL-1
DJNZ 50H,LABEL-2
DJNZ 60H,LABEL-3
willcauseajumpto the instructionat labelLABEL-2 withthe valuesOOH,6FH,and 15Hin
the three W locations The firstjump wasnottakenbecausethe result waszero.
This instructionprovideaa simplewayof executinga programloopa givennumberof times,
or for addinga moderatetime delay (from2 to 512machinecycles)witha singleinstruction.
The instructionsequence,
MOV R2,#8
TOOOLE: CPL P1.7
DJNZ
R2,TOOGLE
will toggleP1.7 eighttimes, causingfour output pukes to appear at bit 7 of output Port 1.
Each pulsewilllast three machinecycles;two for DJNZ and oneto alter the pin.
DJNZ Rn,rel
Bytee: 2
cycles: 2
Encoding:
I
1101
11’”1 EEl
Operation:
DJNZ
(PC!)- (PC) + 2
m) -(w 1
w ~~~ 0 or (I@ < t)
(PC)+ (PC)+ rd
2-43

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Intel MCS 51 and is the answer not in the manual?

Intel MCS 51 Specifications

General IconGeneral
BrandIntel
ModelMCS 51
CategoryMicrocontrollers
LanguageEnglish

Related product manuals