Sie sind auf Seite 1von 13

Program No.

: 2
School of Electronics Engineering
VIT, Vellore

Reg.No 17BEC0901

Student Name Rohan George Joshua

L23+L24,
Course Code ECE3003 Slot & Semester
FALL ~2019-20

Course Name Microcontroller and its applications


Program Title Task 2

Date of
Date of Exp. 1/08/2019 30/08/2019
Submission

Faculty A.Karthikeyan

Submission:
Mail Id :akece3003e1tt724@gmail.com ,
akece3003e2tt724@gmail.com
Mail Subject : REG.Number_L__+L__FALL_19_20
File Name and format : Reg.number.docx (doc) - only
Reg no: Fall 2019-20 ECE3003 - �C and its
applications

MAIL YOUR, DIGITAL ASSIGNMENT , LAB PROGRAMS TO THE ABOVE SAID MAIL ID
And also LOAD YOUR DOCUMENTS BEFORE THE DEAD LINE ON THE INTRANET

Question
1. Write a program to transfer a string of data from code space
starting at address 200H to RAM locations starting at 40H. The data is as shown below:
0200H:DB "VIT UNIVERSITY"
Using the simulator, single-step through the
program and examine the data transfer and registers.

2. Add the following subroutine to the program 1, single-step through the subroutine
and examine the RAM locations. After data has been transferred from ROM space into
RAM, the subroutine should copy the data from RAM locations starting at 40H to RAM
locations starting at 60H.

SENSE, VIT Page 2 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications

1. Aim: To write a program to transfer a string of data from code space


starting at address 200H to RAM locations starting at 40H. The data is as shown below:
0200H:DB "VIT UNIVERSITY"
Using the simulator, single-step through the
program and examine the data transfer and registers.

Tools Required
Algorithm:
1. Transfer a string of data starting from address 200H to RAM locations starting at 40H
using instruction MOVC A,@A+DPTR.
2. Increment DPTR and R0.
3. Decrement R1 till it reaches 0. If R1!=0 we jump(branch instruction) to execute the
program again.

Program:

Memory Label Mnemonics Operands Addressing Machine Memory Type of Comments Flags
mode used cycle Byte Instruction getting
Address
Required Required affected by
the
Instruction.

0000H - ORG 0000H - 1 1 - Origin -


starts at
0000H

0E0H - MOV A,#00H Immediat 1 2 Data Move -


SENSE, VIT Page 3 of 13
Reg no: Fall 2019-20 ECE3003 - �C and its
applications
e transfer 300H
into ACC

082H - MOV DPTR, Immediat 2 3 Data Move -


e transfer 200H
#200H
into
DPTR

01H - MOV R1,#0EH Immediat 1 2 Data Move -


e transfer 0EH into
R1

00H - MOV R0,#40H Immediat 1 2 Data Move -


e transfer 40H into
R0

0E0H LOOP CLR A Register 1 1 Logical Clears -


the ACC

0E0H - MOVC A, Indexed 2 1 Data Move -


@A+DPTR register transfer code
byte at
ACC+DP
TR to
ACC

40H - MOV @R0, A Register 1 1 Data Move -


indirect transfer data
from A
to RAM
location
in R0

- INC DPTR Register 2 1 Arithme Increme -


tic nt DPTR

00H - INC R0 Register 1 1 Arithme Increme -


tic nt R0

01H - DJNZ R1,LOOP Register 2 2 Branch Decreme -


nt R1 till
0, jump
if R1 !=0

- HERE SJMP HERE - 2 2 Branch Short -


jump to
HERE

SENSE, VIT Page 4 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications
200H - ORG 200H - 1 1 - Origin -
starts at
200H

- - DB “VIT - - - Data Define -


UNIVERSIT transfer byte
Y”

- - END - 1 1 - End of -
.asm
source
file

Output :
R0=0x4E
R1=0x00
R2=0x00
R3=0x00
R4=0x00
R5=0x00
R6=0x00
R7=0x00
A=0x59
SP=0x07
DPTR=0x020E
Manual Calculation :
R0=40H+0EH=4EH
DPTR=200H+0EH=20EH

SENSE, VIT Page 5 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications

A=”Y”=59H

Results and Observations


Print Screen of the Program and registers before execution:

Print Screen of the Program and registers after execution:

SENSE, VIT Page 6 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications

Inferences:
1. The code has been shifted to addresses starting from 40H from 200H.

2. Since the code in DB occupies 0E bytes R0=40H+0EH=4EH

3. Since the last letter is “Y” A=59H in ascii.

Result: The 8051 ALP successfully transferred code starting from 200H to addresses
starting from 40H using keil software and the results are verified manually.

SENSE, VIT Page 7 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications

2. Aim: To add the following subroutine to the program 1, single-step through the
subroutine and examine the RAM locations. After data has been transferred from ROM
space into RAM, the subroutine should copy the data from RAM locations starting at
40H to RAM locations starting at 60H.
Tools Required
Algorithm:
4. Transfer a string of data starting from address 200H to RAM locations starting at 40H
using instruction MOVC A,@A+DPTR.
5. Increment DPTR and R0.
6. Decrement R1 till it reaches 0. If R1!=0 we jump(branch instruction) to execute the
program again.
7. Copy the code from addresses starting from 40H to addresses starting from 60H
8. Increment R0 and R1
9. Decrement R3 till it reaches 0. If R3!=0 we jump(branch instruction) to execute the
program again.

Program:

Memory Label Mnemonics Operands Addressing Machine Memory Type of Comments Flags
mode used cycle Byte Instruction getting
Address
Required Required affected by

SENSE, VIT Page 8 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications
the
Instruction.

0000H - ORG 0000H - 1 1 - Origin -


starts at
0000H

0E0H - MOV A,#00H Immediat 1 2 Data Move -


e transfer 300H
into ACC

082H - MOV DPTR, Immediat 2 3 Data Move -


e transfer 200H
#200H
into
DPTR

01H - MOV R1,#0EH Immediat 1 2 Data Move -


e transfer 0EH into
R1

00H - MOV R0,#40H Immediat 1 2 Data Move -


e transfer 40H into
R0

0E0H LOOP CLR A Register 1 1 Logical Clears -


the ACC

0E0H - MOVC A, Indexed 2 1 Data Move -


@A+DPTR register transfer code
byte at
ACC+DP
TR to
ACC

40H - MOV @R0, A Register 1 1 Data Move -


indirect transfer data
from
ACC to
RAM
location
in R0

- INC DPTR Register 2 1 Arithme Increme -


tic nt DPTR

00H - INC R0 Register 1 1 Arithme Increme -


tic nt R0

01H - DJNZ R1,LOOP - 2 2 Branch Decreme -


SENSE, VIT Page 9 of 13
Reg no: Fall 2019-20 ECE3003 - �C and its
applications
nt R1 till
0, jump
if R1 !=0

00H - MOV R0,#40H Immediat 1 2 Data Move -


e transfer 40H to
R0

01H - MOV R1,#60H Immediat 1 2 Data Move -


e transfer 60H to
R1

03H - MOV R3,#0EH Immediat 1 2 Data Move -


e transfer 0EH to
R3

0EH LOOP CLR A Register 1 1 Logical Clear the -


2 ACC

0EH - MOV A,@R0 Register 1 1 Data Move -


indirect transfer data
from
RAM
location
in R0 to
ACC

60H - MOV @R1,A Register 1 1 Data Move -


indirect transfer data
from
ACC to
RAM
location
in R1

00H - INC R0 Register 1 1 Arithme Increme -


tic nt R0

01H - INC R1 Register 1 1 Arithme Increme -


tic nt R1

03H - DJNZ R3,LOOP2 - 2 2 Branch Decreme -


nt R3 till
0, jump
if R1 !=0

SENSE, VIT Page 10 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications
- HERE SJMP HERE - 2 2 Branch Short -
jump to
HERE

200H - ORG 200H - 1 1 - Origin -


starts at
200H

- - DB “VIT - - - Data Define -


UNIVERSIT transfer byte
Y”

- - END - 1 1 - End of -
.asm
source
file

Output :
R0=0x4E
R1=0x6E
R2=0x00
R3=0x00
R4=0x00
R5=0x00
R6=0x00
R7=0x00
A=0x59
SP=0x07
DPTR=0x020E
Manual Calculation :
R0=40H+0EH=4EH
SENSE, VIT Page 11 of 13
Reg no: Fall 2019-20 ECE3003 - �C and its
applications

R1=60H+0EH=6EH
DPTR=200H+0EH=20EH
A=”Y”=59H

Results and Observations


Print Screen of the Program and registers before execution:

Print Screen of the Program and registers after execution:

SENSE, VIT Page 12 of 13


Reg no: Fall 2019-20 ECE3003 - �C and its
applications

Inferences:
1. The code has been shifted to addresses starting from 40H from 200H.

2. The code has been copied from addresses starting from 40H to addresses starting from 60H.

3. Since the code in DB occupies 0E bytes R0=40H+0EH=4EH and R1=60H+0EH=6EH

3. Since the last letter is “Y” A=59H in ascii.

Result: The 8051 ALP successfully transferred code starting from 200H to addresses
starting from 40H and then copied the code from addresses starting at 40H to addresses
starting from 60H using keil software and the results are verified manually.

SENSE, VIT Page 13 of 13

Das könnte Ihnen auch gefallen