Beruflich Dokumente
Kultur Dokumente
: 1
School of Electronics Engineering
VIT, Vellore
Reg.No 15BMD0020
L51+L52
Course Code ECE3023 Slot & Semester
Win ~2017-18
Date of 11/01/2018
Date of Exp. 21/12/2017
Submission
Faculty A.Karthikeyan
Submission:
Mail Id : da.ece3023@gmail.com
Mail Subject : REG NO:_L +L Win_1718_Reg.number
File Name and format : Reg.number.docx (doc) - only
MAIL YOUR, DIGITAL ASSIGNMENT , LAB PROGRAMS TO THE ABOVE SAID MAIL ID
And also LOAD YOUR DOCUMENTS BEFORE THE DEAD LINE ON THE INTRANET
Reg no: 15BMD0020 Win~2017-18 ECE3023 - 𝜇C and its applications
Question
1. 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 an 8051 ALP to load values into registers R0-R4 and then push them onto the stack
ALGORITHM:
1) Start the program at origin=0
2) Load values 25H, 35H, 45H, 55H, 65H onto registers R0, R1, R2, R3 and R4 respectively.
3) Use the “push” instruction to push the register values onto the stack. The contents of the
register are then saved onto the stack.
PROGRAM:
Label Mnemonic Operand Comment Flags getting
affected by the
Instruction.
ORG 000H ;START (ORIGIN) AT
LOCATION 0
MOV R0, #25H ;LOAD 25H INTO R0
MOV R1, #35H ;LOAD 35H INTO R1
MOV R2, #45H ;LOAD 45H INTO R2
MOV R3, #55H ;LOAD 55H INTO R3
MOV R4,#65H ;LOAD 65H INTO R4
PUSH 0 ;PUSH R0 ONTO STACK
PUSH 1 ;PUSH R1 ONTO STACK
PUSH 2 ;PUSH R2 ONTO STACK
PUSH 3 ;PUSH R3 ONTO STACK
PUSH 4 ;PUSH R4 ONTO STACK
END ;END OF ASM FILE
MANUAL CALCULATIONS:
Inferences:
1. Stack value decrements after execution of “push” instruction.
RESULT: The 8051 ALP to load values onto registers R0-R4 and push the registers onto stack is
executed using keil software and the results are verified manually
Question
AIM: To write an 8051 ALP to set stack pointer to 0D, load values into RAM locations 0D, 0C,
0B, 0A, 09, and 08, and then pop them into registers R0-R4.
ALGORITHM:
1) Start the program at origin=0
2) Load 0 onto stack pointer.
3) Load values 11H, 12H, 13H, 14H, 15H onto RAM locations 08, 09, 0A, 0B, 0C and 0D
respectively.
4) Use the “pop” instruction to pop the stack onto the registers. The contents of the stack
are then saved onto the register.
PROGRAM:
Label Mnemonic Operand Comment Flags getting
affected by
the
Instruction.
ORG 000H ;START (ORIGIN) AT
LOCATION 0
MOV SP, #0DH ;LOAD 0 INTO STACK
POINTER
MOV 08H, #10H ;LOAD 10H INTO 08
MOV 09H, #11H ;LOAD 11H INTO 09
MANUAL CALCULATIONS:
Inferences:
1. Stack value increments after execution of “pop” instruction.
RESULT: The 8051 ALP to load values into RAM locations 0D, 0C, 0B, 0A, 09, and 08, and then
pop them into registers R0-R4 is executed using keil software and the results are verified manually
Question
3. 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 an 8051 ALP to load values onto registers R0-R4, push them onto the stack and
then pop them into registers R0-R4.
ALGORITHM:
1) Start the program at origin=0
2) Load values 25H, 35H, 45H, 55H, 65H onto registers R0, R1, R2, R3 and R4
respectively.
3) Use the “push” instruction to push the register values onto the stack. The contents of
the register are then saved onto the stack.
4) Use the “pop” instruction to then pop the stack onto the registers. The contents of the
stack are then saved onto the register.
PROGRAM:
Label Mnemonic Operand Comment Flags getting
affected by
the
Instruction.
ORG 000H ;START (ORIGIN) AT
LOCATION 0
MOV R0, #25H ;LOAD 25H INTO R0
MOV R1, #35H ;LOAD 35H INTO R1
MOV R2, #45H ;LOAD 45H INTO R2
MOV R3, #55H ;LOAD 55H INTO R3
MOV R4,#65H ;LOAD 65H INTO R4
PUSH 0 ;PUSH R0 ONTO STACK
PUSH 1 ;PUSH R1 ONTO STACK
PUSH 2 ;PUSH R2 ONTO STACK
PUSH 3 ;PUSH R3 ONTO STACK
PUSH 4 ;PUSH R4 ONTO STACK
POP 0 ;POP STACK ONTO R0
POP 1 ;POP STACK ONTO R1
POP 2 ;POP STACK ONTO R2
POP 3 ;POP STACK ONTO R3
POP 4 ;POP STACK ONTO R4
END
OUTPUT: Registers contain results R0= 65H, R1=55H, R2=45H, R3=35H, R4=25H
MANUAL CALCULATIONS:
Inferences:
1. Stack value decrements after execution of “push” instruction and increments after execution of “pop”
instruction.
RESULT: The 8051 ALP to load values onto registers R0-R4, push them onto the stack and then
pop them into registers R0-R4 is executed using keil software and the results are verified manually
Question
4. 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
SENSE, VIT Page 8 of 14
Reg no: 15BMD0020 Win~2017-18 ECE3023 - 𝜇C and its applications
UNIVERSITY" Using the simulator, single-step through the program and examine
the data transfer and registers.
AIM: To write an 8051 ALP program to transfer a string of data from code space starting at
address 200H to RAM locations starting at 40H
ALGORITHM:
1) Start the program at origin=0
2) Set DPTR which points to required address (200H).
3) Load the values then form a loop.
4) In the loop clear the accumulator, move the values stored in the addresses to A using
DPTR and R0. Increment the value of DPTR and R0 such that the loop runs till R2=0, while
decrementing the value of R2.
5) This will lead to transfer of the string characters.
PROGRAM:
Label Mnemonic Operand Comment Flags getting
affected by
the
Instruction.
ORG 000H ;START (ORIGIN) AT
LOCATION 0
MOV DPTR,#0200H ;DPTR POINTS TO
ADDRESS 200H
MOV R2,#0EH ;LOAD 0EH INTO R2
MOV R0, #40H ;LOAD 40H INTO R0
LOOP: CLR A ;CLEAR ACCUMULATOR
MOVC A,@A+DPTR ;VALUE STORED IN THE
ADDRESS POINTED TO
BY DPTR+A MOVED TO A
MOV @R0,A ;VALUE STORED IN THE PARITY FLAG
ADDRESS POINTED TO
BY R0 MOVED TO A
INC DPTR ;DPTR VALUE
INCREASES
INC R0 ;R0 VALUE INCREASES
DJNZ R2,LOOP ;LOOPS TILL R2=0 WHILE
DECREMENTING R2
EACH TIME
HERE: SJMP HERE ;UNCONDITIONAL JUMP
TO STAY ON THIS LINE
ORG 0200H
DB “VIT ;SAVES STRING IN ROM
Result: The 8051 ALP to transfer a string of data from code space starting at address
200H to RAM locations starting at 40H is executed using keil software and the
results are verified manually
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 program to transfer a string of data from code space starting at
address 200H to RAM locations starting at 40H and then copy data from RAM locations
starting at 40H to 60H.
ALGORITHM:
1) Start the program at origin=0
2) Set DPTR which points to required address (200H).
3) Load the values then form a loop.
4) In the loop clear the accumulator, move the values stored in the addresses to A using
DPTR and R0. Increment the value of DPTR and R0 such that the loop runs till R2=0, while
decrementing the value of 2.
5) In the second loop, clear the accumulator, move the values stored in the addresses to A
using R1. Increment the value of R1 and R0 such that the loop runs till R3=0, while
decrementing the value of R3.
6) This will lead to transfer of the string characters to 60H.
PROGRAM:
Label Mnemonic Operand Comment Flags getting
affected by the
Instruction.
ORG 000H ;START (ORIGIN) AT
LOCATION 0
MOV DPTR,#0200H ;DPTR POINTS TO
ADDRESS 200H
MOV R2,#0EH ;LOAD 0EH INTO R2
MOV R0, #40H ;LOAD 40H INTO R0
LOOP1: CLR A ;CLEAR ACCUMULATOR
SENSE, VIT Page 11 of 14
Reg no: 15BMD0020 Win~2017-18 ECE3023 - 𝜇C and its applications
MOVC A,@A+DPTR ;VALUE STORED IN THE
ADDRESS POINTED TO
BY DPTR+A MOVED TO
A
MOV @R0,A ;VALUE STORED IN THE PARITY FLAG
ADDRESS POINTED TO
BY R0 MOVED TO A
INC DPTR ;DPTR VALUE
INCREASES
INC R0 ;R0 VALUE INCREASES
DJNZ R2,LOOP1 ;LOOPS TILL R2=0
WHILE DECREMENTING
R2 EACH TIME
MOV R0,#40H ;LOAD 40H INTO R0
MOV R1,#60H ;LOAD 60H INTO R1
MOV R3,#0EH ;LOAD 0EH INTO R3
LOOP2: CLR A ;CLEAR ACCUMULATOR
MOV A,@R0 ;VALUE STORED IN THE
ADDRESS POINTED TO
BY R0 MOVED TO A
MOV @R1,A ;VALUE STORED IN THE PARITY FLAG
ADDRESS POINTED TO
BY R1 MOVED TO A
INC R0 ;R0 VALUE INCREASES
INC R1 ;R1 VALUE INCREASES
DJNZ R3,LOOP2 ;LOOPS TILL R3=0
WHILE DECREMENTING
R3 EACH TIME
ORG 0200H
DB ‘VIT ;SAVES STRING IN ROM
UNIVERSITY’ LOCATION STARTING
FROM 200H
END
Inferences:
Data or strings can be transferred from ROM to different locations in the RAM.
Result: The 8051 ALP to transfer a string of data from code space to RAM and then copy data
from RAM locations starting at 40H to 60H is executed using keil software and the results are
verified manually.
SENSE, VIT Page 13 of 14
Reg no: 15BMD0020 Win~2017-18 ECE3023 - 𝜇C and its applications