Use of CJNE and LJMP or SJMP instruction in micro controller

CJNE:- Compare and jump if not equal(CY Flag)

Program to use of this instruction by comparing two value

             Program                                     Description
             mov       R1,#80h                   ;load the 80 hexadecimal code in R1 register
  Here:  mov       A,R1                         ;move value of R1 in Accumulator (Here is a label)
            CJNE     A,#50 , Here             ;Compare accumulator value with 50 , if equal than
                                                              execute next instruction otherwise jump to Here label

LJMP:- Long jump
SJMP:- Short jump

These two instructions are used to short and long jump on any subroutine program.here is a program in which a received value is comes into SBUF (instruction)  which is move continuously into Accumulator
and check with a register value if these value is same than jump on a subroutine program by using LJMP or SJMP instruction

Assembly Program for receiving data into sbuf and compare and jump to a sub routine program if value are equal :-

                Program                                     Description
                org0000h
                mov       R0,#67h                       ;load the 67 in R0 register
                mov       A,SBUF                       ;copy the value from Sbuf to A
      Here: CJNE   A,R0,Here      ;compare and jump if not equal , if equal execute next instruction
                Sjmp      Here2                           ;short jump on any subroutine program
                 — —  —
                  — — —
                    — —  —
      Here2: write here a subroutine program

 

Leave a Comment