Professional Documents
Culture Documents
No 19BEC0532
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:
L4
END
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
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
L35+L36
Course Code ECE3003 Slot & Semester
FALL - 2021-22
Date of
Date of Exp.
Submission
Faculty A.Karthikeyan
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
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
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.
Output :
Registers containing the Result R0=65H,R1=55H,R2=45H,R3=35H,R4=25H
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
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