0% found this document useful (0 votes)
103 views25 pages

Upload Lab 1

The document summarizes two programs written in 8051 assembly language to add numbers. The first program adds the register number 01H, 5BH, 0ECH, 07H, 60H and verifies that the carry flag is set correctly. The second program adds five 8-bit numbers (FFH, FFH, FFH, FFH, FFH) and also verifies the carry flag. Both programs are implemented using KEIL software and results are verified manually.

Uploaded by

Aditya Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views25 pages

Upload Lab 1

The document summarizes two programs written in 8051 assembly language to add numbers. The first program adds the register number 01H, 5BH, 0ECH, 07H, 60H and verifies that the carry flag is set correctly. The second program adds five 8-bit numbers (FFH, FFH, FFH, FFH, FFH) and also verifies the carry flag. Both programs are implemented using KEIL software and results are verified manually.

Uploaded by

Aditya Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Reg.

No 15BEC0760

Student Name ADITYA.G.KULKARNI

L43+L44
Course Code ECE3003 Slot & Semester
WIN-2019-20

Course Name Microcontroller and its applications

Program Title TO ADDING GIVEN DATAS

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

Label Mnemonics Operands Addressing Machine Memory Type of Comments Flags


mode cycle byte Instruction getting
required required affected
by the
instruction
ORG 0000H ASSEMBLY
DIRECTIVE
MOV A, #01H Immediate 1 2 Data transfer Load 01H
address into
mode accumulator
MOV R0, #5BH Immediate 1 2 Data transfer Load 5B
address into R1
Mode
ADD A, R0 Register 1 1 arithmetic Adding A
addressing and R0
mode saved at A
JNC L1 2 2 Bit Check jump
manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L1: Loop
purpose
MOV R1,#ECH Immediate 1 2 Data transfer Transfer EC
address to R1
mode
ADD A,R1 Register 1 1 arithmetic Adding A
addressing and R1
mode
JNC L2 2 2 Bit manu- Check jump
pulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L2: Loop
purpose
MOV R2, #07H Immediate 1 2 Data transfer Transfer 07
address to R2
mode
ADD A, R2 Register 1 1 arithmetic Adding A
addressing and R2
mode
JNC L3 2 2 Bit manu- Check jump
pulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L3: Loop
purpose
MOV R3, #60H Immediate 1 2 Data transfer Transfer 60
address to R3
mode
ADD A, R3 Register 1 1 arithmetic Adding A
addressing and R3
mode
JNC L4 2 2 Bit Check jump
manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L4: Loop
purpose
END End of
program

OUTPUT
A – D7H
CARRY-1

MANUAL CALCULATION:
01H: 0000 0001
5BH: 0101 1011
------------------------------
A: 0101 1100  5CH
ECH: 1110 1100
---------------------------------

A: 1 0100 1000 1 48H


07H: 0000 0111
----------------------------------
A: 1 0100 1111  14FH
60H: 0110 0000
-----------------------------------
A: 1 1010 1111  1 AFH
INFERENCE:
The number 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 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:

 Start the program.


 Move the value 0FFH to the A register, 0FFH 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.
FFH, FFH, FFH, FFH, FFH

Label Mnemonics Operands Addressing Machine Memory Type of Comments Flags


mode cycle byte Instruction getting
required required affected
by the
instruction
ORG 0000H ASSEMBLY
DIRECTIVE
MOV A, #FFH Immediate 1 2 Data transfer Load FF
address into
Mode accumulator
MOV R0, #FFH Immediate 1 2 Data transfer Load FF
address into R1
Mode
ADD A, R0 Register 1 1 arithmetic Adding A
addressing and R0
Mode saved at A
JNC L1 2 2 Bit Check jump
manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L1: Loop
purpose
MOV R1, #FFH Immediate 1 2 Data transfer Transfer FF
address to R1
mode
ADD A, R1 Register 1 1 arithmetic Adding A
addressing and R1
mode
JNC L2 2 2 Bit Check jump
Manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L2: Loop
purpose
MOV R2, #FFH Immediate 1 2 Data transfer Transfer FF
address to R2
mode
ADD A, R2 Register 1 1 arithmetic Adding A
addressing and R2
mode
JNC L3 2 2 Bit Check jump
manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L3: Loop
purpose
MOV R3, Immediate 1 2 Data transfer Transfer
#0FFH address 0FF to R3
mode
ADD A, R3 Register 1 1 arithmetic Adding A
addressing and R3
mode
JNC L4 2 2 Bit Check jump
manipulation on no carry
INC R7 1 1 arithmetic R7 increase
when carry
found
L4: Loop
purpose
END End of
program

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

ORG 0000H Assembly No


directive

MOV R0,#01H Immediate 1 2 Data Load 01H No


addressing transfer into R0
mode
MOV R1, #02H Immediate 1 2 Data Load 02H No
addressing transfer into R1
mode
MOV R2, Immediate 1 2 Data Load No
#03H addressing transfer 03H into R2
mode
MOV R3, #04H Immediate 1 2 Data Load 04H No
addressing transfer into R3
mode
MOV R4, #05H Immediate 1 2 Data Load 05H No
addressing transfer into R4
mode
PUSH 0 Stack and 2 2 Data Push 01 No
direct transfer into stack
addressing
mode
PUSH 1 Stack and 2 2 Data Push 02 No
direct transfer into stack
addressing
mode
PUSH 2 Stack and 2 2 Data Push 03 No
direct transfer into stack
addressing
mode
PUSH 3 Stack and 2 2 Data Push 04 No
direct transfer into stack
addressing
mode
PUSH 4 Stack and 2 2 Data Push 05 No
direct transfer into stack
addressing
mode
End End of the
program
OUTPUT:
05
04
03
02

01

MANUAL CALCULATION:

PUSH 0 PUSH 1 PUSH 2 PUSH 3 PUSH 4 STACK

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

3. 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.

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

ORG 0000H Assembly No


directive

MOV SP, #0DH Immediate 1 2 Data Load the


addressing transfer stack
mode pointer
value is
DH
MOV 08H, #01H Immediate 1 2 Data Load 01H No
addressing transfer into R0
mode
MOV 09H, Immediate 1 2 Data Load 5BH No
#5BH addressing transfer into R1
mode
MOV 0A, Immediate 1 2 Data Load ECH No
#0ECH addressing transfer into R2
mode
MOV 0B, #07H Immediate 1 2 Data Load 07H No
addressing transfer into R3
mode
MOV 0C, #60H Immediate 1 2 Data Load 60H No
addressing transfer into R4
mode
POP 0 Stack and 2 2 Data POP 01 No
direct transfer into stack
addressing
mode
POP 1 Stack and 2 2 Data POP 7B No
direct transfer into stack
addressing
mode
POP 2 Stack and 2 2 Data POP EC No
direct transfer into stack
addressing
mode
POP 3 Stack and 2 2 Data POP 08 No
direct transfer into stack
addressing
mode

POP 4 Stack and 2 2 Data POP 67 No


direct transfer into stack
addressing
mode
End End of
program
OUTPUT:
60
07
EC
5B
01
MANUAL CALCULATION:

POP 0 POP1 POP2 POP 3 POP 4 STACK

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

ORG 0000H Assembly No


directive

MOV R0, #01H Immediate 1 2 Data Load 01H No


addressing transfer into R0
mode
MOV R1, #5BH Immediate 1 2 Data Load 5BH No
addressing transfer into R1
mode
MOV R2, Immediate 1 2 Data Load ECH No
#0ECH addressing transfer into R2
mode
MOV R3, #07H Immediate 1 2 Data Load 07H No
addressing transfer into R3
mode
MOV R4, #60H Immediate 1 2 Data Load 60H No
addressing transfer into R4
mode
PUSH 0 Stack and 2 2 Data Push 01 No
direct transfer into stack
addressing
mode
PUSH 1 Stack and 2 2 Data Push 7B No
direct transfer into stack
addressing
mode
PUSH 2 Stack and 2 2 Data Push EC No
direct transfer into stack
addressing
mode
PUSH 3 Stack and 2 2 Data Push 08 No
direct transfer into stack
addressing
mode
PUSH 4 Stack and 2 2 Data Push 67 No
direct transfer into stack
addressing
mode
POP 0 Stack and 2 2 Data POP 01 No
direct transfer into stack
addressing
mode
POP 1 Stack and 2 2 Data POP 7B No
direct transfer into stack
addressing
mode
POP 2 Stack and 2 2 Data POP EC No
direct transfer into stack
addressing
mode
POP 3 Stack and 2 2 Data POP 08 No
direct transfer into stack
addressing
mode

POP 4 Stack and 2 2 Data POP 67 No


direct transfer into stack
addressing
mode
End End of
program

OUTPUT:
PUSH POP
67 67
08 08
EC EC
7B 7B
01 01

PUSH 0 PUSH 1 PUSH 2 PUSH 3 PUSH 4


STACK

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.

You might also like