0% found this document useful (0 votes)
19 views

Control System by Norman Nise Sixth Ed

Uploaded by

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

Control System by Norman Nise Sixth Ed

Uploaded by

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

TASK 1

School of Electronics Engineering


VIT, Vellore

Reg.No 24MEA0018

Student Name M HARSHITH

L33+L34
Course Code MAME502P Slot & Semester
FALL ~ 2024-25

Course Name M.Tech Automotive Electronics

Program Title Microcontrollers for Vehicular Systems Lab

Date of
Date of Exp. 24/07/2024 10/08/2024
Submission

Faculty Dr. Karthikeyan A


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
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 "REGISTER NUMBER" AND 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 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
EXPERIMENT 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 "REGISTER NUMBER" AND VIT UNIVERSITY
Aim: To write an 8051 ALP to transfer a string of data from starting at address 200H to RAM
locations starting at 40H. [ 0200H:DB "REGISTER NUMBER" AND VIT UNIVERSITY]
Tools Required:
Keil version5 Software.
Algorithm:
1. Set the origin address of the program to 000H.
2. Load the data pointer (DPTR) with the memory address 200H.
3. Load the immediate value 0EH and 40H into registers R1 and R0.
4. Start a loop labelled "LOOP".
- Clear the accumulator (A) register.
- Move a byte of data from the address pointed to by (A + DPTR) to the accumulator using the
MOVC instruction.
- Move contents of A into RAM location whose address is held by R0
- Decimal adjusts the accumulator after addition.
- If no carry occurred during addition, jump to the label "NEXT".
- Increment DPTR
- Increment R0.
- Decrement the value in register R1 (DJNZ) and jump back to "LOOP" if R0 is not zero.
- Jump back to the beginning of the loop ("LOOP").
5. Label "HERE":
- Loop indefinitely by jumping back to the same label.
6. Set the origin address to 200H.
7. Define a data block (DB) with string data.
8. End program
Program:

Label Mnemonics Operands Addressing Type of Comments Flags


mode used Instruction getting
affected by
the
Instruction
ORG 0000H
MOV DPTR, #200H Immediate Data Transfer Load DPTR=200
SENSE, VIT Page 3 of 12
Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Addressing Instruction DPTR with H
Mode 200H
MOV R1, #0EH Immediate Data Transfer Load R1 R1=0EH
Addressing Instruction with 0EH
Mode
MOV R0, #40H Immediate Data Transfer Load R0 R0=40H
Addressing Instruction with 40H
Mode
LOOP CLR A Logical Clear A
: Instruction

MOVC A, @A+DPTR Index Data Transfer A<- A=V


memory Instruction @A+DPT
addressing R
mode
MOV @R0, A Register Data Transfer @R0<- A 40H=V
Indirect Instruction
addressing
Mode
INC DPTR Register Arithmetic Increment
addressing Instruction DPTR
mode
INC R0 Register Arithmetic Increment
addressing Instruction R0
mode
DJNZ R1, LOOP Branching Decrement
Instruction R1 and
jump to
LOOP if
not zero
HERE SJMP HERE Branching Unconditional
: Instruction jump back to
Label HERE
ORG 0200H
DB ‘VIT
UNIVERSITY

END

Output: Memory window containing the Result:


c:200H
0X200H: VIT UNIVERSITY…..
d:40H
0X40H: VIT UNIVERSITY…..

SENSE, VIT Page 4 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Results and Observations
Case 1:
Program and registers before execution:

Program and registers after execution:

SENSE, VIT Page 5 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Case 2:
Program and registers before execution:

Program and registers after execution:

SENSE, VIT Page 6 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Manual Calculation:

Inferences:
1. The string data is transferred from code space to RAM location.
2. The DPTR points to the source memory location, and another pointer to point to the destination
memory location.
3. After transferring each byte, pointer is incremented to the next byte in the string.
Result:
The 8051 ALP to perform string transfer from code space to RAM location is executed using keil
software.

SENSE, VIT Page 7 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
EXPERIMENT 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.
Aim: To write an 8051 ALP to transfer a string of data from starting at address 200H to RAM
locations starting at 40H.
Tools Required:
Keil version5 Software.
Algorithm:
1. Set the origin address of the program to 000H.
2. Load the data pointer (DPTR) with the memory address 200H.
3. Load the immediate value 0EH and 40H into registers R1 and R0.
4. Start a loop labelled "LOOP".
- Clear the accumulator (A) register.
- Move a byte of data from the address pointed to by (A + DPTR) to the accumulator using the
MOVC instruction.
- Move contents of A into RAM location whose address is held by R0.
- If no carry occurred during addition, jump to the label "NEXT".
- Increment DPTR.
- Increment R0.
- Decrement the value in register R1 (DJNZ) and jump back to "LOOP" if R1 is not zero.
- Jump back to the beginning of the loop ("LOOP").
5. Load the immediate value 40H, 60H and 0EH into registers R0, R1 and R3.
6. Start a loop labelled “LOOP2”
- Clear the accumulator (A) register.
- Move contents of RAM location whose address is held by R0 into A.
- Move contents of A into RAM location whose address is held by R0.
- If no carry occurred during addition, jump to the label "NEXT".
- Increment R0.
- Increment R1.
- Decrement the value in register R3 (DJNZ) and jump back to "LOOP2" if R3 is not zero.
- Jump back to the beginning of the loop ("LOOP2").
7. Label "HERE":
- Loop indefinitely by jumping back to the same label.
8. Set the origin address to 200H.

SENSE, VIT Page 8 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
9. Define a data block (DB) with string data.
10. End program
Program:

Label Mnemonics Operands Addressing Type of Comments Flags


mode used Instruction getting
affected by
the
Instruction
ORG 0000H
MOV DPTR, #200H Immediate Data Transfer Load DPTR=200
Addressing Instruction DPTR with H
Mode 200H
MOV R1, #0EH Immediate Data Transfer Load R1 R1=0EH
Addressing Instruction with 0EH
Mode
MOV R0, #40H Immediate Data Transfer Load R0 R0=40H
Addressing Instruction with 40H
Mode
LOOP CLR A Logical Clear A
: Instruction

MOVC A, @A+DPTR Index Data Transfer A<- A=V


memory Instruction @A+DPT
addressing R
mode
MOV @R0, A Register Data Transfer @R0<- A 40H=V
Indirect Instruction
addressing
Mode
INC DPTR Register Arithmetic Increment
addressing Instruction DPTR
mode
INC R0 Register Arithmetic Increment
addressing Instruction R0
mode
DJNZ R1, LOOP Branching Decrement
Instruction R1 and
jump to
LOOP if
not zero
MOV R0, #40H Immediate Data Transfer Load R0 R0=40H
Addressing Instruction with 40H
Mode

SENSE, VIT Page 9 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
MOV R1, #60H Immediate Data Transfer Load R1 R1=60H
Addressing Instruction with 60H
Mode
MOV R3, #0EH Immediate Data Transfer Load R3 R3=0EH
Addressing Instruction with 40H
Mode
LOOP CLR A Logical Clear A
2: Instruction

MOV A, @R0 Register Data Transfer A<-@R0 A=V


Indirect Instruction
addressing
Mode
MOV @R1, A Register Data Transfer @R1<- A 60H=V
Indirect Instruction
addressing
Mode
INC R0 Register Arithmetic Increment
addressing Instruction R0
mode
INC R1 Register Arithmetic Increment
addressing Instruction R1
mode
DJNZ R3, LOOP2 Branching Decrement
Instruction R1 and
jump to
LOOP if
not zero
HERE SJMP HERE Branching Unconditional
: Instruction jump back to
Label HERE
ORG 0000H
DB ‘VIT
UNIVERSITY

END

Output: Memory window containing the Result:


c:200H
0X200H: VIT UNIVERSITY…..
d:40H
0X40H: VIT UNIVERSITY…..
d:60H
0X60H: VIT UNIVERSITY…..
SENSE, VIT Page 10 of 12
Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Results and Observations
Program and registers before execution:

Program and registers after execution:

SENSE, VIT Page 11 of 12


Reg no: 24MEA0018 Fall 2024-25 MAME502P Microcontrollers for Vehicular Systems
Manual Calculation:

Inferences:
1. The string data is transferred from code space to RAM location.
2. The data is transferred from one part of RAM location to another part of RAM location.
3. Two looping instruction is used in the program to transfer the data.
Result:
The 8051 ALP to perform string transfer from code space to RAM location and to transfer from
one part of RAM location to another part of RAM location is executed using keil software.

SENSE, VIT Page 12 of 12

You might also like