You are on page 1of 38

Reg.

No 19BEC0532

Student Name PONUKU SARAH

Slot & L35+L36


Course Code ECE3003
Semester FALL - 2021-22

Course Name Microcontroller and its applications

Write an 8051 ALP to add the following data


and then use the simulator to examine the CY
flag.

Program Title a) INPUT DATA YOUR REG NO:


b) Five max 8BIT NUMBERS (FF
,FF,FF,FF,FF)

Date of
Date of Exp.
Submission

Faculty A.Karthikeyan

TASK 1
Write an 8051 ALP to add the following data and then use the
simulator to examine the CY flag.
a) INPUT DATA YOUR REG NO: 19BEC0532
b) Five max 8BIT NUMBERS (FF ,FF,FF,FF,FF)

AIM: To write an 8051 ALP to perform addition of 5 8BIT NUMBERS using keil
software and to verify the result manually.
TOOLS REQUIRED: Keil Micro vision Software.
ALGORITHM:
1. First move the 0ffh to accumulator a .
2.Move the second operand to accumulator b.
3. Add a and b and store the result in b.
4. Move to level L1 if there is no carry.
5.Incrementtheregistervalue r0 by 1.
6.Repeat the step1to5fourmore time.
7.Jump to level 4 if there is no carry and end the program.
PROGRAM:

LAB MNEUM OPERA ADDRES MACHI MEMO TYPE OF COMM FLAGS


EL ONICS NDS SING NE RY INSTRU ENTS GETTI
MODES CYCLE BYTE CTION NG
USED S REQUI AFFEC
RED TED
BY
THE
INSTR
UCTIO
N

ORG 0000H Direct 1 1 Memory Start the


Addressin Addressi
g mode ng
program
Mode at
0000
(starting
address
of the
program)

MOV A,01H Immediate 1 2 Memory Move the


Addressin content to
g mode the
accumula
tor A

MOV B,9BH Immediate 1 2 Memory Move the


addressing content to
mode the
accumula
tor B
ADD A,B Register 1 2 Arithemeti Add A
indirect c and B
addressing

L1 JNC Implicit 2 2 conditiona Jump to In psw


addressing l level 1 if Carry
mode there is flag-1
no carry accumul
ator 1 p-
1

INC R0 Implicit 1 1 conditiona Incremen


addressing l t the
mode register
r0 value
by 1

L1 MOV B,A Register 1 2 Memory Move the


Direct content of
Addressin the
g Mode accumula
tor A to B

MOV A,0ECH Immediate 1 2 Memory Move the


addressing content to
mode the
accumula
tor A

ADD A,B Register 1 2 Arithmetic Add and In psw


Indirect b p-0 acc-
Addressin 1 cy-1
g

JNC Implicit 2 2 Condition Jump to In psw


Addressin al level 2 if p-1
g mode there is
no carry acc-1
cy-1

INC R0 Implicit 1 1 Condition Incremen


addressing al t the
mode register
r0 value
by 1

L2 MOV B,A Registeer 1 2 Memory Move the


direct content b
addressing to a
mode

MOV A,05H Immediate 1 2 Memory Move the


addressing content to
mode accumula
tor

ADD A,B Register 1 2 Arithemeti Add A In psw


indirect c and B p-0
Addressssi Acc-1
ng
Cy-1

JNC L3 Implicit 2 2 Condition Jump to


addressing al L3 if
mode there is
no carry

INC R0 Implicit 2 2 conditiona Incremen


addressing l t the
mode register
R0 by 1

L3 MOV B,A Register 1 2 Memory Move the


Direct content
addressing from b to
mode a

MOV A,32H Immediate 1 2 Memory Move the


addressing content to
mode a

ADD A,B Register 1 2 Arithemeti Add A


indirect c and B
adressing

JNC L4 Implicit 2 2 conditiona Jump to In psw


addressing l l4 if there p-1
mode is no
carry acc-1
cy-1

INC R0 Implicit 1 1 conditiona Increase


Addressin l the R0 if
g mode there is
no carry

L4

END

Output : Registers containing the Result:


RO=01,R1=00,R2=00,R3=00,R4=00,R5=00,R6=00,R7=00,a=c8,cy=0
Manual Calculation :
01+9B=9C
9C+EC=188
188+05=18D
8D+32=1BF
Results and Observations
a) Print Screen of the Program and registers before execution:

Print Screen of the Program and registers after execution:


b)Print Screen of the Program and registers before execution:

Print Screen of the Program and registers after execution:


INFERENCES
A.
1. The R0 registers stores value of 01H.
2. The carry flag(cy) has a value of 0.
B.
1. The R0 registers stores value of 04H.
2. The carry flag(cy) has a value of 1.
Result:
The 8051 ALP to perform addition of 5 8BIT NUMBERS is executed
using keil software and the results are verified manually.
Reg.No 19BEC0532

Student Name PONUKU SARAH

Slot & L35+L36


Course Code ECE3003
Semester FALL - 2021-22

Course Name Microcontroller and its applications

Write and assemble a program to load values into each of


registers R0 – R5 and then push each of these registers
Program Title onto the stack. Single-step the program, and examine the
stack and the SP register after the execution of each
instruction.

Date of
Date of Exp.
Submission

Faculty A.Karthikeyan
Aim: Write and assemble a program to load values into each of registers R0 – R5
and then push each of these registers onto the stack. Single-step the program, and
examine the stack and the SP register after the execution of each instruction.
Tools Required-KEIL IDE

Algorithm:
1.First move the values to the registers R0,R1,R2,R3,R4.
2.Then Push each of the registers using ‘PUSH ‘ simultaneously.
3.End the program.

PROGRAM:
Lab Mnemo Opera Addresss Machi Mem Type of Comme Flags
el nics nds ing ne ory Instruct nts getting
modes cycle byte ion affecte
used used requir d by
ed the
instruct
ion
ORG 0000H Direct 1 1 memor Start
addressi y the
ng mode progra
m at
0000
MOV R0,25 Immedia 1 2 memor Moves
H te y the
addressi content
ng mode to the
register
R0
MOV R1,35 Immedia 1 2 memor Move
H te y the
addressi content
ng mode to the
register
R1
MOV R2,45 Immedia 1 2 memor Move
H te y the
addressi content
ng mode to
register
R2
MOV R3,55 Immedia 1 2 memor Move
H te y the
addressi content
ng mode to
register
R3
MOV R4,65 Immedia 1 2 memor Move
H te y the
addressi content
ng mode s to
register
R4
MOV R5,75 Immedia 1 2 memor Move
H te y the
addressi content
ng mode s to
register
R5
PUSH R0 Register 2 2 memor PUSH SP
direct y R0 to change
addressi stack s to 08
ng mode
PUSH R1 Register 2 2 memor PUSH SP
direct y R1 to change
addressi stack s to 09
ng mode
PUSH R2 Register 2 2 memor Push SP
direct y R2 to change
addressi stack s to 0A
ng mode
PUSH R3 Register 2 2 memor Push SP
direct y R3 to change
addressi stack s to 0B
ng mode
PUSH R4 Register 2 2 memor PUSH SP
direct y R4 to change
addressi stack s to 0c
ng mode
PUSH R5 Register 2 2 memor PUSH SP
direct y R5 to change
addressi stack s to OD
ng mode
END

Output :
Registers containing the Result:
SP = 0C, R0 = 25, R1 = 35, R2 = 45, R3 = 55, R4 = 65,R5=75
Manual Calculation:
25H pushed to the location 08
35H pushed to the location 09
45H pushed to the location 0a
55H pushed to the location 0b
65H pushed to the location 0c
75H pushed to the location 0d

RESULT AND OBSERVATIONS


Print Screen of the Program and registers before execution
After execution:

Inference
1. The SP register finally has a value of 0dH.
2. The registers were moved into the stack as seen in the memory window.
Result:
The 8051 load values into each of registers R0 – R5 and then push each of these
registers onto the stack is executed using keil software and the results are verified
manually.

Reg.No 19BEC0532

Student Name PONUKU SARAH

L35+L36
Course Code ECE3003 Slot & Semester
FALL - 2021-22

Course Name Microcontroller and its applications


Write an 8051 assemble language program to:
(a) Set SP = 0D,
(b) Load a different value in each of RAM locations 0D, 0C,
0B, 0A, 09, and 08,
Program Title
(c) POP each stack location into registers R0 - R4. Use the
simulator to single-step and examine the registers, the stack,
and the stack pointer.

Date of
Date of Exp.
Submission

Faculty A.Karthikeyan

AIM :Write an 8051 assemble language program to:


(a) Set SP = 0D,
(b) Load a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,
(c) POP each stack location into registers R0 - R4. Use the simulator to single-step
and examine the registers, the stack, and the stack pointer.

Tools Required-KEIL IDE


Algorithm:
1. Set SP = 0D.
2.Then Pop each of the registers using ‘POP ‘ simultaneously.
3. Set SP = 0D. First Load a different value in each of RAM locations 0D, 0C, 0B,
0A, 09, and 08,.
4.End the program.

PROGRAM:
LA MNEU OPER ADDR MAC MEM TYPE COM FLAGS
BE MONIC AND ESSIN HIEN ORY OF MENT GETTIN
L S S G E BYT INSTRU S G
MODE CYCL ES CTIONS AFFEC
USED ES REQ TED BY
REQ UIRE THE
UIRE D INSTRU
D CTIONS
ORG 0000 Direct 1 1 memory Start
H address the
ing progra
mode m at
0000
MOV 08H,1 Immedi 1 2 memory Move
0H ate the
address conten
ing ts to
mode RAM
locatio
n:08
MOV 09H,1 Immedi 1 2 memory Move
1H ate the
address conten
ing ts to
mode RAM
locatio
n :09
MOV 0AH, Immedi 1 2 memory Move
12H ate the
address conten
ing ts to
mode RAM
locatio
n :0A
MOV 0BH,1 Immedi 1 2 memory Move
3H ate the
address conten
ing ts to
mode RAM
locatio
n :0B
MOV 0CH,1 Immedi 1 2 memory Move
4H ate the
address conten
ing ts to
mode RAM
locatio
n :0C
MOV 0DH, Immedi 1 2 memory Move
16H ate the
address conten
ing ts to
mode RAM
locatio
n :0D
POP R0 Registe 2 2 memory POP
r direct the
address conten
ing t to
mode registe
r to R0
POP R1 Registe 2 2 memory POP
r direct the
address conten
ing t to
mode registe
r to R1
POP R2 Registe 2 2 memory POP
r direct the
address conten
ing t to
mode registe
r to R2
POP R3 Registe 2 2 memory POP
r direct the
address conten
ing t to
mode registe
r to R3
POP R4 Registe 2 2 memory POP
r direct the
address conten
ing t to
mode registe
r to R4
END

Output :
Registers containing the Result: R0=16,R1=14,R2=13,R3=12,R4=11
Manual Calculation:
10H popped to the register R0
11H popped to the register R1
12H popped to the register R2
13H popped to the register R3
14H popped to the register R4

Results and Observations


Print Screen of the Program and registers before execution:
After execution:

Inferences:
1.SP value is 08.
2. The stack values were moved into the registers as seen in the memory window.

Result: The 8051 ALP to POP each stack location into registers R0 - R4. is
executed using keil software and the results are verified manually.

Reg.No 19BEC0532

Student Name PONUKU SARAH

Slot & L35+L36


Course Code ECE3003
Semester FALL - 2021-22

Course Name Microcontroller and its applications

Write and assemble a program to load values into each of


registers R0 - R4 and then push each of these registers
onto the stack and pop them back. Single-step the
Program Title program, and examine the stack and the SP register after
the execution of each instruction.

Date of
Date of Exp.
Submission

AIM:
Faculty A.Karthikeyan Write
and
assemble a program to load values into each of registers R0 - R4 and then push
each of these registers onto the stack and pop them back. Single-step the program,
and examine the stack and the SP register after the execution of each instruction.

Tools Required-KEIL IDE


Algorithm:
1.First move the values to the registers R0,R1,R2,R3,R4.
2.Then Push each of the registers using ‘PUSH ‘ simultaneously.
3.Then Pop each of the registers using ‘POP ‘ simultaneously.
4.End the program.
PROGRAM
LA MNEU OPER ADDR MAC MEM TYPPE COM FLAGS
BE MONIC ANDS ESSIN HINE ORY OF MENT GETTI
L S G CYC BYT INSTR S NG
MODE LE R UCTIO AFFEC
S REQ REQ N TED
USED UIRE UIRE BY
D D THE
INSTR
UCTIO
N
ORG 0000H DIREC 1 1 MEMO STAR
T RY T THE
ADRES PROG
SING RAM
MODE AT
0000
MOV R0,35 IMME 1 2 MEMO MOVE
H DIATE RY THE
ADDR CONT
ESSIN ENT
G TO
MODE THE
REGIS
TE R0
MOV R1,35 IMME 1 2 MEMO MOVE
H DIATE RY THE
ADDR CONT
ESSIN ENT
G TO
MODE THE
REGIS
TE R1
MOV R2,45 IMME 1 2 MEMO MOVE
H DIATE RY THE
ADDR CONT
ESSIN ENT
G TO
MODE THE
REGIS
TE R0
MOVE
THE
CONT
ENT
TO
THE
REGIS
TE R2
MOV R3,55 IMME 1 2 MEMO MOVE
H DIATE RY THE
ADDR CONT
ESSIN ENT
G TO
MODE THE
REGIS
TE R3
MOV R4,65 IMME 1 2 MEMO MOVE
H DIATE RY THE
ADDR CONT
ESSIN ENT
G TO
MODE THE
REGIS
TE R4
PUSH R0 REGIS 2 2 MEMO PUSH
TER RY THE
DIREC CONT
T ENT
ADDR TO
ESS THE
MODE STAC
K
PUSH R1 REGIS 2 2 MEMO PUSH
TER RY THE
DIREC CONT
T ENT
ADDR TO
ESS THE
MODE STAC
K
PUSH R2 REGIS 2 2 MEMO PUSH
TER RY THE
DIREC CONT
T ENT
ADDR TO
ESS THE
MODE STAC
K
PUSH R3 REGIS 2 2 MEMO PUSH
TER RY THE
DIREC CONT
T ENT
ADDR TO
ESS THE
MODE STAC
K
PUSH R4 REGIS 2 2 MEMO PUSH
TER RY THE
DIREC CONT
T ENT
ADDR TO
ESS THE
MODE STAC
K
POP R8 REGIS 2 2 MEMO POP
TER RY THE
DIREC CONT
T ENT
ADDR TI
ESSIN THE
G REGIS
MODE TER
R0
POP R9 REGIS 2 2 MEMO POP
TER RY THE
DIREC CONT
T ENT
ADDR TI
ESSIN THE
G REGIS
MODE TER
REGIS R1
TER
DIREC
T
ADDR
ESSIN
G
MODE
POP R0A REGIS 2 2 MEMO POP
TER RY THE
DIREC CONT
T ENT
ADDR TI
ESSIN THE
G REGIS
MODE TER
R2
POP R0B REGIS 2 2 MEMO POP
TER RY THE
DIREC CONT
T ENT
ADDR TI
ESSIN THE
G REGIS
MODE TER
R3
POP R0C REGIS 2 2 MEMO POP
TER RY THE
DIREC CONT
T ENT
ADDR TI
ESSIN THE
G REGIS
MODE TER
R4
END

Output :
Registers containing the Result R0=65H,R1=55H,R2=45H,R3=35H,R4=25H

Results and Observations


Print Screen of the Program and registers before execution:
After execution:

Inferences:
1. The final value of SP is 07.
2. First registers were moved into the stack and then stack values were popped
back to the registers which can be seen in the memory window.
Result: The 8051 ALP to load values into each of registers R0 - R4 and then push
each of these registers onto the stack and pop them back is executed using keil
software and the results are verified manually.
Reg.No 19BEC0532

Student Name PONUKU SARAH

Slot & L35+L36


Course Code ECE3003
Semester FALL - 2021-22

Course Name Microcontroller and its applications

write a program to add 10 bytes of BCD data and store


Program Title the result in R2 and R3. The bytes are to be stored in
ROM space starting at 300H.

Date of
Date of Exp.
Submission

Faculty A.Karthikeyan

Aim: To write a program to add 10 bytes of BCD data and store the result in R2
and R3. The bytes are to be stored in ROM space starting at 300H.
Tools Required: Keil software
Algorithm:
1. Store the location value in DPTR
2. Store the number of inputs value in R0 register
3. After clearing the contents of A, the data at address which has value of sum of
A and DPTR.
4. Adding R2 and A and then convert that into BCD.
5. R3 will get incremented only if there is a carry and then increment DPTR.
6. A is then copied to R2 and the process is repeated 10 times (since R0 = 10H)

PROGRAM
L MNE OPERANDS ADD MA ME TYPE COM FLA
A UMO RES CHI MO OF MEN GS
B NICS SIN NE RY INSTRU TS GET
E G CYC BY CTION TING
L MO LE TE AFF
DE REQ RE ECT
USE UIR QUI ED
D ED RE BY
D THE
INST
RUC
TION
ORG 0000H DIR 1 1 MEMO STAR
ECT RY T
ADD THE
RES PROG
SIN RAM
G AT
MO 0000
DE
MOV DPTR#300H IMM 1 2 MEMO MOV
EDI RY E
ATE 300H
ADD TO
RES THE
SIN REGI
G STER
MO DPTR
DE
MOV R0 #10H IM 1 2 MEM MOV
ME ORY E 10
DIA TO
TE THE
AD REGI
DRE STE
SIN R R0
G
MO
DE
L CLR A REG 1 1 MEMO CLEA
O ISTE RY R
O R THE
P: INDI CONT
REC ENTS
T OF A
ADD
RES
SIN
G
MOV A,@A+DPTR IND 2 1 MEMO ADD P
C EXE RY A WIL
D AND L
ADD DPTR KEE
RES .THE P
SIN DATA CHA
G AT NGI
MO THIS NG
DE LOCA
TION
IS
THEN
STOR
ED IN
A
ADD A,R2 REG 1 2 ARITHE ADD
ISTE METIC A
R AND
INDI R2
REC
T
ADD
RES
SIN
G
DA A REG 1 1 ARITHE VALU
ISTE METIC E OF
R A IS
INDI CON
REC VERT
T ED
ADD TO
RES BCD
SIN
G
JNC NEXT IMP 2 2 LOGIC/ JUMP
LICI CONDI TO
T TIONA LABE
ADD L L
RES NEXT
SIN IF
G THER
MO E IS
DE NO
CARR
Y
INC R3 IMP 1 2 ARITHE INCR
LICI METIC EME
T NT R3
ADD BY 1
RES
SIN
G
MO
DE
N INC DPTR IMP 1 1 ARITHE INCR
E LICI METIC EME
X T MODE NT
T ADD DPTR
RES BY 1
SIN
G
MO
DE
MOV R2,A REG 1 1 MEMO MOV
ISTE RY ET
R HE
DIR CONT
ECT ENT
ADD OF A
RES TO R2
SIN
G
MET
HOD
MOV A,#08H IMM 1 2 MEMO MOV
EDI Y E 08
ATE TO
ADD ACCU
RES MUL
SIN ATOR
G A
MO
DE
DJNZ R0,LOOP IMP 2 2 CONDI DECR
LICI TIONA EME
T L NT R0
ADD BY1
RES AND
SIN IF
G NON-
MO ZERO
DE JUMP
TO
LOOP
H SJMP IMP 2 2M TRANS
E HER LICI EM FERRIN
R E T OR G THE
E ADD Y EXECU
RES TION
SIN TO THE
G BELOW
MO PROVI
DE DED
ADDRE
SS
ORG 300H DIR 1 1 MEMO SPECI
ECT RY FYIN
ADD G
RES THE
SIN STAR
G T
MO ADD
DE RESS
DB A)22H,43H,23H,3 MEMO MOV
4H,31H,77H,91H, RY E
33H,43H,7H THE
B)01H,9BH,0ECH CONT
,05H,32H,00H,00 ENTS
H,00H,00H,00H FRO
MB
TO A
END

Output:
R2 = 04H, R3 = 04H
Results and Observations
A) Print Screen of the Program and registers before execution:

After execution:
b) Print Screen of the Program and registers before execution:

After execution:
Inferences:
a)R2 = 04H, R3 = 04H.
b) R2=91H,R3=02H
Result: The 8051 ALP to perform BCD addition of 10bytes of data is executed
using keil software and the results are verified manually

You might also like