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

Lab 3A Examining The Cy Flag and The Stack

This lab focuses on examining the CY flag and stack of the 8051 microcontroller. It has three activities: 1) Write a program to add several numbers and examine the CY flag, 2) Write a program to push registers onto the stack and examine the stack and SP register, 3) Write a program to set SP=0D, put values in RAM locations, and pop locations into registers to examine registers, stack, and SP. The worksheet has questions about finding CY flag values, the initial SP value, how SP is affected by push/pop, changing SP, and the RAM bank used by the stack.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Lab 3A Examining The Cy Flag and The Stack

This lab focuses on examining the CY flag and stack of the 8051 microcontroller. It has three activities: 1) Write a program to add several numbers and examine the CY flag, 2) Write a program to push registers onto the stack and examine the stack and SP register, 3) Write a program to set SP=0D, put values in RAM locations, and pop locations into registers to examine registers, stack, and SP. The worksheet has questions about finding CY flag values, the initial SP value, how SP is affected by push/pop, changing SP, and the RAM bank used by the stack.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB 3A

EXAMINING THE CY FLAG AND THE STACK


OBJECTIVES:
To examine the flag bits of the PSW.
To examine the stack.
REFERENCE:
Mazidi and McKinlay, The 8051 Microcontroller , Chapter 2 and 3.
MATERIALS:
8051 assembler and simulator.
ACTIVITY 1
Write and assemble a program to add the following data and then use the simulator to
examine the CY flag.
92H, 23H, 66H, 87H, F5H
ACTIVITY 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.
ACTIVITY 3
Write and assemble a program to:
(a) Set SP = 0D,
(b) Put 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.

Lab Manual for The 8051 Microcontroller .

LAB 3A
WORKSHEET
Name:

Date:

Class:

1. Find the value of the CY flag after the execution of the following code.
(a)

MOV A,#85H
ADD A,#92H

(b)

MOV A,#15H
ADD A,#72H

(c)

MOV A,#0F5H
ADD A,#52H

(d)

MOV A,#0FF
INC A

2. Upon reset, what is the value in the SP register?


3. Upon pushing data onto the stack, the SP register is _____________
(decremented,
incremented).

4. Upon popping data from the stack, the SP register is ___________


(decremented,
incremented).

5. Can you change the value of the SP register? If yes, explain why you
would want
to do that.

Lab Manual for The 8051 Microcontroller .

LAB 3A
EXAMINING THE CY FLAG AND THE STACK
6. The stack uses the same area of RAM as bank ______.

Lab Manual for The 8051 Microcontroller .

You might also like