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

Examining The Cy Flag and The Stack (8051) : Objectives

The document examines the CY flag and stack operations using the 8051 microcontroller. It provides 3 programs: 1) Adds several numbers and checks the CY flag, 2) Pushes registers R0-R4 onto the stack and examines the stack and SP, 3) Sets SP=0D, stores values in RAM 08H-0DH, and pops them into registers R0-R4.

Uploaded by

aksdaf
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)
370 views

Examining The Cy Flag and The Stack (8051) : Objectives

The document examines the CY flag and stack operations using the 8051 microcontroller. It provides 3 programs: 1) Adds several numbers and checks the CY flag, 2) Pushes registers R0-R4 onto the stack and examines the stack and SP, 3) Sets SP=0D, stores values in RAM 08H-0DH, and pops them into registers R0-R4.

Uploaded by

aksdaf
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/ 3

EXAMINING THE CY FLAG AND THE STACK [8051]

OBJECTIVES:
 To examine the flag bits of the PSW.
 To examine the stack.

REFERENCE:
 Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems,”
Chapter 2.

MATERIALS:
 8051 KEIL IDE.

Program 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

Code:

Org 0000h
MOV A,#92H; 23H, 66H, 87H, F5H
MOV B,#23H
ADD A,B
JNC L1
INC R0
L1: MOV B,A
MOV A,#66H
ADD A,B
JNC L3
INC R0
L2: MOV B,A
MOV A,#87H
ADD A,B
JNC L3
INC R0
L3: MOV B,A
MOV A,#0F5H
ADD A,B
JNC L4
INC R0
L4:
END

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

Code:

ORG 000H
MOV R0,#01H
MOV R1,#07H
MOV R2,#09H
MOV R3,#05H
MOV R4,#03H
PUSH 0
PUSH 1
PUSH 2
PUSH 3
PUSH 4
END

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

Code:

ORG 0000H
MOV SP,#0DH
MOV 0DH, #10H
MOV 0CH, #11H
MOV 0BH, #12H
MOV 0AH, #13H
MOV 09H,#14H
MOV 08,#16H
POP 0
POP 1
POP 2
POP 3
POP 4
END

You might also like