8051 Instruction Set Manual

CJNE

The CJNE instruction compares the first two operands and branches to the specified destination if their values are not equal. If the values are the same, execution continues with the next instruction.

See Also: DJNZ

CJNE @Rn, #immediate, offset
CACF0RS1RS0OV P
Bytes3
Cycles2
Encoding
1011011nimmediateoffset
Operation
CJNE
PC = PC + 3
IF (Rn) <> immedate
  PC = PC + offset
IF (Rn) < immediate
  C = 1
ELSE
  C = 0
Example
CJNE @R1, #24H, LABEL
CJNE A, #immediate, offset
CACF0RS1RS0OV P
Bytes3
Cycles2
Encoding
10110100immediateoffset
Operation
CJNE
PC = PC + 3
IF A <> immediate
  PC = PC + offset
IF A < immediate
  C = 1
ELSE
  C = 0
Example
CJNE A, #01H, LABEL
CJNE A, direct, offset
CACF0RS1RS0OV P
Bytes3
Cycles2
Encoding
10110101directoffset
Operation
CJNE
PC = PC + 3
IF A <> (direct)
  PC = PC + offset
IF A < (direct)
  C = 1
ELSE
  C = 0
Example
CJNE A, 60h, LABEL
CJNE Rn, #immediate, offset
CACF0RS1RS0OV P
Bytes3
Cycles2
Encoding
10111nnnimmediateoffset
Operation
CJNE
PC = PC + 3
IF Rn <> immedate
  PC = PC + offset
IF Rn < immediate
  C = 1
ELSE
  C = 0
Example
CJNE R6, #12H, LABEL

Related Knowledgebase Articles