it@l.
MCS'@-51 PROGRAMMER'S GUIDE AND INSTRUCTION SET
CJNE <dest-byte>,<src-byte>, rel
Function:
Description:
Compareand Jump if Not Equal.
CJNE comparesthe magnitudesof the fmt two operands,and branches if their valuesare not
equal. The branch destinationis computedby addingthe signedrelative-displacement i n the
last instructionbyte to the PC, after incrementingthe PC to the start of the next instruction.
The carry flag is set if the unsignedinteger value of <dest-byte> is less than the unsigned
integer valueof <src-byte>; otherwise,the carry is cleared. Neither operand is tided.
The first two operands allow four addressingmode combinations:the Accumulatormay be
comparedwith any directlyaddressedbyte or immediateda~ and any indirectRAM location
or worldngregister can be comparedwith an immediateconstant.
The Accumulator contains 34H. Register 7 contains 56H. The first instruction in the se-
quence
CJNE R7,#60H, NOT-EQ
. . . . .
; R7 = 60H.
NOT—EQ:
"'"
JC
REoLLOw
; IF R7 < &3H.
. . .
. . . . .
; R7 > 60H.
sets the carry flag and branchesto the instructionat labelNOT-EQ. Bytestingthe carry flag,
this instructiondetermines whether R7 is greater or less than 60H.
If the data being presentedto Port 1 is also 34H, then the instruction,
WAIT: CJNE A,P1,WAIT
clears the carry tlag and continueswith the next instructionin sequence,sincethe Accumula-
tor doesequal the data read from P1. (If someother valuewas beinginput on Pl, the program
will loopat this point until the PI data changesto 34H.)
CJNE A,direct,rel
Bytes:
3
Cycles:
2
Encoding:
1o11
0101
I 'ire"addressI
EiEl
Operation:
(PC) -
(PC) + 3
IF (A) <> (direct)
THEN
(PC) + (PC) + relativeoffket
IF (A) <
(direct)
THEN
~L~E
(c) -1
(c)+ o
2-35
Need help?
Do you have a question about the MCS 51 and is the answer not in the manual?