Page 172 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 172
Introduction to Microprocessors Dinesh Kumar, Lovely Professional University
Notes Unit 12: The Stacks
CONTENTS
Objectives
Introduction
12.1 Stack
12.1.1 Stack in main memory
12.1.2 Stack in registers or dedicated memory
12.2 Saving Information on the Stack
12.3 PUSH & POP
12.3.1 The PUSH Instruction
12.3.2 The POP Instruction
12.3.3 Operation of the Stack
12.4 The PSW Register Pair
12.4.1 PUSH PSW (1 Byte Instruction)
12.4.2 Pop PSW Register Pair
12.4.3 Modify Flag Content using PUSH/POP
12.5 Summary
12.6 Keywords
12.7 Self-Assessment Questions
12.8 Review Questions
12.9 Further Reading
Objectives
After studying this unit, you will able to understand the following:
• Discuss about the use of stack in memory
• Explain about how to save the information on stack
• Discuss about the operations on stack
Introduction
The stack is one of the most important things you must know when programming. Think of the
stack as a deck of cards. When you put a card on the deck, it will be the top card. Then you put
another card, then another. When you remove the cards, you remove them backwards, the last
card first and so on. The stack works the same way, you put (push) words (addresses or register
pairs) on the stack and then remove (pop) them backwards. That's called LIFO, Last In First Out.
The 8085 uses a 16 bit register to know where the stack top is located, and that register is called
the SP (Stack Pointer). There are instructions that allow you to modify it's contents but you should
NOT change the contents of that register if you don't know what you're doing?
166 LOVELY PROFESSIONAL UNIVERSITY