0% found this document useful (0 votes)
10 views4 pages

EEE 15EE63C U2 S11 Sy

Uploaded by

Abhishek Abhi
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)
10 views4 pages

EEE 15EE63C U2 S11 Sy

Uploaded by

Abhishek Abhi
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/ 4

EMBEDDED SYSTEMS - 15EE63C 2020-21

UNIT 2

Stack and Stack Pointer

Session 11

Stack and its Operations


Stack in the 8051
In the 8051, the stack pointer (SP) points to the last used location of the stack. When
data is pushed onto the stack, the stack pointer (SP) is incremented by 1. To push the
registers onto the stack, we must use their RAM addresses. For example, the
instruction "PUSH 1" pushes register R1 onto the stack.

The stack is a section of a RAM used by the CPU to store information such as data or
memory address on temporary basis. The CPU needs this storage area considering
limited number of registers.

STACK in 8051

Stack Pointer, PUSH and POP:

 The register used to access the stack is called the SP (stack pointer) register
 The stack pointer in the 8051 is only 8 bit wide, which means that it can take
value of 00 to FFH
 When the 8051 is powered up, the SP register contains value 07.
 RAM location 08 is the first location begins used for the stack by the 8051.
 The storing of a CPU register in the stack is called a PUSH
 SP is pointing to the last used location of the stack
 As we push data onto the stack, the SP is incremented by one
 This is different from many microprocessors
 Loading the contents of the stack back into a CPU register is called a POP
 With every pop, the top byte of the stack is copied to the register specified by
the instruction and the stack pointer is decremented once.

Diploma in Electrical and Electronics Engineering 1


EMBEDDED SYSTEMS - 15EE63C 2020-21

When the 8051 is initialized, the SP register contains the value 07H. This means that
the RAM location 08 is the first location used for the stack. The storing operation of
a CPU register in the stack is known as a PUSH, and getting the contents from the
stack back into a CPU register is called a POP.

 The following examples illustrates the Stack, Stack pointer, PUSH and POP
operations :

When executing PUSH instructions:

MOV R6, #25H

MOV R1, #12H

MOV R4, #0F3H

PUSH 6

PUSH 1

PUSH 4

Diploma in Electrical and Electronics Engineering 2


EMBEDDED SYSTEMS - 15EE63C 2020-21

When executing POP instructions:

PUSH 3

PUSH 5

PUSH 2

POP 3 ; POP stack into R3 = 54

POP 5 ; POP stack into R5 = F9

POP 2 ; POP stack into R2 = 76

Diploma in Electrical and Electronics Engineering 3


EMBEDDED SYSTEMS - 15EE63C 2020-21

Reference Books:
1. The 8051 Microcontrollers-II edition-Kenneth j Ayala. Perram Publications.
2. Embedded system Design-Frank Vahid /Tony Givargis WSE. Wiley Publications.
3. 8051 Microcontroller-Hardware, Software and applications-V Udayashankara / M
S Mallikarjunaswamy - Tata McGraw Hill.

e- Resources:
1) YouTube videos on interfacing various peripherals and devices

2) www.microdigital.com

Model Question Bank

Cognitive Level: Remember


1. Explain briefly stack and stack pointer.

Cognitive Level: Understand


1. Explain stack operation in 8051.

XXXXXXXXXXXXXXXXX

Diploma in Electrical and Electronics Engineering 4

You might also like