Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

8051 MICROCONTROLLER

II CYCLE:

1. Assembly Language Programs to Perform Arithmetic (Both Signed and Unsigned) 16 Bit Data Operations,
Logical Operations (Byte and Bit Level Operations), Rotate, Shift, Swap and Branch Instructions

a) 8-bit Addition:
AIM: To perform 8 bit addition by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV A,#02H
MOV B,#02H
ADD A,B
END
OUTPUT:

b) 8 bit subtraction:
AIM: To perform 8 bit subtraction by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV A,#04H
MOV B,#02H
SUBB A,B
END
OUTPUT:

c) 8 bit multiplication:
AIM: To perform 8 bit multiplication by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV DPTR,#9000H
MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
MUL AB
INC DPTR
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
End
OUTPUT:
d) 8 bit division:
AIM: To perform 8 bit division by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV DPTR,#9000H
MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
DIV AB
INC DPTR
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
End
OUTPUT:

e) 8 bit AND Logic:


AIM: To perform 8 bit AND logic by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV R0,#40H
MOV A,@R0
INC R0
MOV B,@R0
ANL A,B
INC R0
MOV @R0,A
End
OUTPUT:

f) 8 bit OR Logic:
AIM: To perform 8 bit OR logic by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV R0,#40H
MOV A,@R0
INC R0
MOV B,@R0
ORL A,B
INC R0
MOV @R0,A
End
OUTPUT:
g) 8 bit EX-OR Logic:
AIM: To perform 8 bit EX-OR logic by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV R0,#40H
MOV A,@R0
INC R0
MOV B,@R0
ORL A,B
INC R0
MOV @R0,A
End
OUTPUT:

h) 16 bit addition:
AIM: To perform 16 bit addition by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV DPTR,#2040H
MOV A,#20H
MOV B,#31H
ADD A,DPL
MOV DPL,A
MOV A,B
ADDC A,DPH
MOV DPH,A
End
OUTPUT:

i) 16 bit subtraction:
AIM: To perform 16 bit subtraction by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV DPTR,#2040H
MOV A,#20H
MOV B,#31H
SUBB A,DPL
MOV DPL,A
MOV A,B
SUBB A,DPH
MOV DPH,A
End
OUTPUT:
J) Program with Rotate and swap instructions :
AIM: To perform 8 bit rotate and swap by using 8051.
APPARATUS: 8051 with keyboard/Keil software.
PROGRAM:
MOV A,#20H
MOV B,#31H
RL A
MOV R0,A
SETB C
MOV A,B
RRC A
SWAP A
End
OUTPUT:

You might also like