Upload Lab 1
Upload Lab 1
No 15BEC0760
L43+L44
Course Code ECE3003 Slot & Semester
WIN-2019-20
Faculty Dr.A.Karthikeyan
1. Write and assemble a program to add the following data and then use the simulator to
examine the CY flag. . INPUT DATA REG NO: Example 01 5B EC 07 70. Five max 8BIT
NUMBERS (FF ,FF,FF,FF,FF).
AIM:
To write 8051 ALP to perform addition of REG.NO using keil software and
verify the result manually.
ALGORITHM:
Start the program.
Move the value 01H to the A register, 5B to the R0 register.
Add the content of A and R0 register
Use jump on no carry to find carry
Next increment the R7 register when the carry appears.
Next move the content of A register from the R0 register. Again, do the
same process for other values.
Stop the program
PROGRAM:
Write an assemble program to add the following data and then use the simulator
to examine the CY flag.
01H, 5BH, 0ECH, 07H, 60H
OUTPUT
A – D7H
CARRY-1
MANUAL CALCULATION:
01H: 0000 0001
5BH: 0101 1011
------------------------------
A: 0101 1100 5CH
ECH: 1110 1100
---------------------------------
RESULT:
The 8051 ALP to perform addition of REG.NO is executed using keil software
and the results are verified.
Expt. 2
AIM:
To write 8051 ALP to perform addition of 5 max 8 BIT NUMBERS using keil
software and verify the result manually.
ALGORITHM:
PROGRAM:
Write an assemble program to add the following data and then use the simulator
to examine the CY flag.
FFH, FFH, FFH, FFH, FFH
OUTPUT:
A – 0FBH
CARRY-1
MANUAL CALCULATION:
FFH: 1111 1111
FFH: 1111 1111
-------------------------------
A: 1 1111 1110 FEH
FFH: 1111 1111
--------------------------------
A: 1 1111 1101 FDH
FFH: 1111 1111
--------------------------------
A: 1 1111 1100 FCH
FFH: 1111 1111
--------------------------------
A: 1 1111 1011 FBH
INFERENCE:
The no of hex numbers is added by string each value in accumulator and add to
the previous summation.
RESULT:
The 8051 ALP to perform addition of 5 8 bit numbers is executed using keil
software and the results are verified.
EXPT 3
2. Write and assemble a program to load values into each of registers
R0 - R4 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.
AIM:
To write and assemble language program for 8051 microcontrollers
for performing PUSH for stack pointer using keil software.
ALGORITHM:
Start the program
Move the values which are given into registers R0-R4.
PUSH each value into the stack. When push the value the stack
pointer value will increase from its default value 0x007.
After finished the PUSH, all the value from the stack. So, the
stack pointer value will decrease.
Stop the program
Mnemonics Operands Addressing Machine Memory Type of Comments Flags
mode cycle byte Instruction getting
required required affected
by the
instruction
01
MANUAL CALCULATION:
0D
05 0C
04 04 0B
03 03 03 0A
02 02 02 02 09
01 01 01 01 01 08
INFERENCE:
*assemble a program to load values into each of registers
*PUSH each value into the stack
Result:
The 8051 ALP to perform PUSH each value into the stack is executed using
keil software and the results are verified manually.
EXPT 4
AIM:
To write and assemble language program for 8051 microcontrollers
for performing POP for stack pointer using keil software
ALGORITHM:
Start the program
Move the values which are given into registers R0-R4.
POP each value into the stack. When pop the value the stack
pointer value will decrease from its default value 0x00D.
After finished the POP, all the value from the stack. So, the
stack pointer value will decrease.
Stop the program
Mnemonics Operands Addressing Machine Memory Type of Comments Flags
mode cycle byte Instruction getting
required required affected
by the
instruction
60 0C
07 07 0B
EC EC EC 0A
5B 5B 5B 5B 09
01 01 01 01 01 08
INFERENCE:
*Load a different value in each of RAM locations
*After finished the POP, all the value from the stack
Result:
The 8051 ALP to perform POP for stack pointer is executed using keil software
and the results are verified manually.
EXPT 5
4. 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.
AIM:
To write and assemble language program for 8051 microcontrollers
for performing PUSH AND POP for stack pointer using keil software
ALGORITHM:
Start the program
Move the values which are given into registers R0-R4.
PUSH AND POP each value into the stack. When push the
value the stack pointer value will increase from its default value
0x007. pop the value the stack pointer value will decrease from
its default value 0x00D.
After finished the PUSH AND POP, all the value from the
stack. So, the stack pointer value will decrease.
Stop the program
Mnemonics Operands Addressing Machine Memory Type of Comments Flags
mode cycle byte Instruction getting
required required affected
by the
instruction
OUTPUT:
PUSH POP
67 67
08 08
EC EC
7B 7B
01 01
0D
60 0C
07 0 0B
EC EC EC 0A
5B 5B 5B 5B 09
01 01 01 01 01 08
POP 0 POP1 POP2 POP 3 POP 4
STACK
60 0D
07 07 0C
EC EC EC 0B
5B 5B 5B 5B 0A
01 01 01 01 01 09
INFERENCE:
*Move the values which are given into registers R0-R4.
*PUSH AND POP each value into the stack.
Result:
The 8051 ALP to perform PUSH and POP for stack pointer is executed using
keil software and the results are verified manually.
EXPT 6
5).Write a program to add 10 bytes of BCD data and store the result in R2
and R3.The bytes are stored in ROM space starting at 300H. The data
would look as follows: MYDATA: DB pick your REG NO AS data. Notice
that you must first bring the data from ROM space into the CPU's RAM,
then add them together. Use a simulator to single-step the program and
examine the data.
AIM:
To write and assemble language program for 8051 microcontrollers for add 10
bytes of BCD data using keil software.
ALGORITHM:
Start the program
Load the memory location value to be store in data pointer and load the
10 into R0
Clear the accumulator and transfer address of A and value of DPTR to the
A register.
Use DA A to decimal adjust accumulator to after addition. Add 6 to the
lower bits of A if it is greater than 0 or if AC=1.
If also adds 6 to the upper 4 bits of A if it is greater than 9 of if CY=1.
Stop the program
Operands Address Machi Memo Type of Comme Flags
Label ing ne ry Instructi nts getting
Mnemo mode cycle byte on affected
nics requir requir by the
ed ed instruct
ion
ORG 0000H Assembl
y
directive
MOV DPTR, immedia 1 2 Data Load
#300H te transfer 300H
into
DPTR
MOV R0, #10 immedia 1 2 Data Load 10
te transfer into R0
LOO CLR A 1 1 Logical Clear
P: accumul
ator
MOVC A, Indexed 2 1 Data Transfer
@A+DPT transfer address
R of A and
value of
DPTR to
the A
register
ADD A, R2 Register 1 1 Arithmeti Add A, Affected
c R2
DA A 1 1 Arithmeti Decimal
c adjust
accumul
ator after
addition
JNC NEXT 2 2 Bit Jump on
manipula no carry
tion
INC R3 1 1 Arithmeti Increme
c nt R3
NEX INC DPTR 1 1 Arithmeti Increme
T: c nt DPTR
MOV R2, A Register 1 1 Data Load A
addressi transfer into R2
ng register
DJNZ R0, LOOP 2 2 Branch Decreme
nt R0
when
found
non-zero
HER SJMP HERE Stay in 2 2 Branch Short
E: this loop jump
ORG 300H Give the
string
using
DB in
address
of 300H
DB 22H,43H,2 Data to
3H,34H,31 000H
H,77H,91H,
33H,43H,0
7H
END End of
the
program
INFERENCE:
*Load the memory location value to be store in data pointer
*Clear the accumulator and transfer address of A and value of DPTR to the A register.
RESULT:
The 8051 ALP to perform add 10 bytes of BCD data using keil software and the results are
verified manually.