Bit instructions in 8051

ORL, ANL, MOV, SETB, CLR, CPL instructions in 8051 are elobarated in the following blog.
SETB instruction in 8051
CLR instruction in 8051
CPL instruction in 8051
ANL instruction in 8051
ORL instruction in 8051
MOV instruction in 8051

SETB instruction in 8051 | CLR instruction in 8051 | CPL instruction in 8051  | ANL instruction in 8051 | ORL instruction in 8051 | MOV instruction in 8051
SETB instruction in 8051
CLR instruction in 8051
CPL instruction in 8051
ANL instruction in 8051
ORL instruction in 8051
MOV instruction in 8051

Instructions for carry flag

SETB  C

SETB instruction in 8051 stands for set the bit which means make bit as 1.

C1  ( Carry flag is given 1 )

CLR  C

CLR instruction in 8051 stands for clear the bit which means make bit as 0.

C0  ( Carry flag is given 0 )

CPL  C

CPL instruction in 8051 stands for complement the bit.

C← C bar ( Carry flag is given it’s complement value)

Instructions for general bits:

These are the bits of 16bytes( second part of RAM, refer memory organization tutorial ) which are bit addressable and bits of few special function registers.

SETB  b

b1  ( general bit is given 1 )

Ex: SETB P0.3

SETB PSW.2

CLR  b

b0  ( general bit  is given 0 )

CPL  b

bb  ( general bit  is given it’s compliment value)

MOV instructions in 8051 for bits:

MOV  C, b

MOV instruction in 8051 stands for move the value from one register to another.

Cb  ( Carry flag is given with the value of b bit )

MOV  P0.2 , P0.5

P0.2 P0.5  ( P0.2 gets the data of P0.5, but not directly )

Firstly assign P0.5 to carry flag

Then mov carry flag to P0.2

MOV C, P0.5 ; 

MOV P0.2, C

AND, OR operations in 8051 :

ANL c,b 

ANL instruction in 8051 stands for AND operation between the values of two registers.

c ← c*b ( c gets the and of c and b bit )

ANL c,b 

c ← c*/b ( c gets the and of c and b’s complement )

ORL c,b 

ORL instruction in 8051 stands for OR operation between the values of two registers

c ← c+b ( c gets the or of c and b bit )

ORL c,b 

c ← c+/b ( c gets the or of c and b’s complement )

for more details about these instructions refer keil webiste.

Read related topics:
Arithmetic instructions of 8051
Logical instructions of 8051

Topics covered:

Topics covered:
SETB instruction in 8051
CLR instruction in 8051
CPL instruction in 8051
ANL instruction in 8051
ORL instruction in 8051
MOV instruction in 8051

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *