Working on...

your queries, use contact form

21 Dec 2021

Program branching and bit manipulation instructions of 8051 microcontroller

 

Program branching instructions of 8051 microcontroller

Program branching instructions are used to access the modules/subroutines or small programs that are written apart from main program to overcome the redundancy in the codes.

Absolute call (ACALL) = 11 bit add

Long call (LCALL)       = 16 bit add

 

ACALL ADD11;

This instruction is absolute subroutine call instruction which specifies 11 bit address and calls subroutines written within 2k memory

 

LCALL ADD16;

This instruction is long subroutine call instruction which specifies 16 bit address and calls subroutines written within 64k memory

 

RET ;

Return from subroutine

 

RETI;

Return from interrupt

 

AJMP ADD11   ;

This instruction is absolute subroutine JUMP instruction which specifies 11 bit address and JUMPS subroutines written within 2k memory

 

 

LJMP ADD16   ;

This instruction is long subroutine JUMP instruction which specifies 16 bit address and JUMPS subroutines written within 64k memory

 

SJMP REL;

(ALTERNATIVE INSTRUCTION FOR END) This is short jump instruction which specifies 8-bit add

 

JZ REL;

Jump to relative address when accumulator is zero

 

JNZ REL;

Jump to relative address when accumulator is non zero

 

CJNE A,DIRECT,REL       ;

Compare direct bit with accumulator and jump to relative address when not equal (compare and jump if not equal)

 

CJNE A,#12H,REL;

Compare 8-bit data with accumulator and jump to relative address when not equal (compare and jump if not equal)

 

DJNZ R0,REL;

Decrement the contents of R0 and jump to relative add if not zero

 

NOP;

No operation

---------------------------------------------------------------------------------------------------------------------------

Bit manipulation instructions

---------------------------------------------------------------------------------------------------------------------------


Bit manipulation instructions

CLR C                 ; clears (0) carry flag

CLR BIT             ; clears bit

SETB C               ; sets (1) carry flag

SETB BIT           ; sets (1) bit

CPL C                 ; complements/inverts carry flag

CPL BIT             ; complements bit

ANL C,BIT         ; AND carry flag and bit      

ANL C,/BIT        ; AND carry flag and inverse of bit

ORL C, BIT        ; OR carry flag and bit

ORL C,/BIT        ; OR carry flag and inverse of bit

MOV C, BIT      ; move direct bit into carry flag

JC REL_ADD    ; Jump to relative address when carry is generated

JNC REL_ADD ; Jump to relative address when there is no carry

JB REL_ADD    ; Jump to relative address when bit is set

JNB REL_ADD ; Jump to relative address when bit is not set


 

No comments:

Post a Comment