SlideShare a Scribd company logo
8086: STACK ORGANISATION
• Stack is a sequence of RAM memory locations defined by the
programmer. Stack mechanism provide a temporary storage
of data.
• Stack is a block of memory locations which is accessed using
the SP and SS register. Stack is a Last In First Out (LIFO) data
segment.
• In the case of subroutine and interrupt, the address of re-
entry into the main program (return address) may be stored
in the stack.
• The process of storing the data in the stack is called Pushing
into the stack.
• The process of transferring the data back from the stack to
the CPU register is called popping off the stack.
STACK STRUCTURE OF 8086
STACK STRUCTURE OF 8086
• Top of stack: Physical address of the last storage location in
the stack to which data were pushed. This address is
obtained from the content of SS and SP ( SS: SP)
• Bottom of stack: At the microcomputer’s startup, the value in
SP is initialized to FFFEH. Combining this value with the
current value in SS gives the highest address word location in
the stack (SS:FFFEH), called bottom of the stack.
• 8086 can push data and address information on to the stack
from its internal register or a storage location in memory.
• Data transferred to and from the stack are word-wide, not
byte-wide
STACK STRUCTURE OF 8086
• Each time a word is to be pushed on to the stack, the value in
SP is automatically decremented by two.
• Therefore, stack grows down in memory from the bottom of
the stack (SS: FFFEH) towards the end of the stack (SS:
0000H)
• Each time a word is popped from the top of stack, the value
in SP is automatically incremented by two
STACK STRUCTURE OF 8086
STACK STRUCTURE OF 8086
Above figure, is the state of stack prior to execution of the
PUSH AX instruction.
The stack segment register contains 1050H. Bottom of
stack address is derived from SS and offset FFFEH
Bottom of stack address = 1050H + FFFEH= 1104EH
SP contains 0008H. Top of stack can be derived from SS
and SP
Top of stack = 1050H + 0008H = 1058H
STACK STRUCTURE OF 8086
AX initially contains the number 1234H.
Execution of push instruction causes the
stack pointer to be decremented by two.
Therefore the next stack access is to the
location corresponding to address 1056H.
This location is where the value in AX is
pushed.
The MSB of AX (ie,12H) resides in memory
address 1057H and LSB of AX (ie, 34H) is
held in memory address 1056H
STACK STRUCTURE OF 8086: PUSH OPERATION
The execution of the first instruction POP
AX, causes the 8086 to read the value from
the Top of the stack and put it in to AX
register as 1234H
SP is incremented to give 0008H and the
other read operation POP BX, causes the
value BBAAH to be loaded into the BX
register.
SP is incremented once more and now
equals 000AH. Therefore , the new top of
stack is at address 105AH
STACK STRUCTURE OF 8086: POP OPERATION
Stack is an area of memory for keeping temporary data. Stack is used by CALL
instruction to keep return address for procedure, RET instruction gets this value
from the stack and returns to that offset.
Quite the same thing happens when INT instruction calls an interrupt, it stores in
stack flag register, code segment and offset. IRET instruction is used to return from
interrupt call.
We can also use the stack to keep any other data, there are two instructions that
work with the stack:
PUSH - stores 16 bit value in the stack.
POP - gets 16 bit value from the stack.
STACK STRUCTURE OF 8086: INSTRUCTIONS
STACK STRUCTURE OF 8086: INSTRUCTIONS
STACK STRUCTURE OF 8086: INSTRUCTIONS
It is very important to do equal number of PUSHs and POPs, otherwise the stack
maybe corrupted and it will be impossible to return to operating system.
As you already know we use RET instruction to return to operating system, so when
program starts there is a return address in stack (generally it's 0000H).
PUSH and POP instruction are especially useful because we don't have too much
registers to operate with,
so here is a trick:
Store original value of the register in stack (using PUSH).
Use the register for any purpose.
Restore the original value of the register from stack (using POP).
STACK STRUCTURE OF 8086: INSTRUCTIONS
STACK STRUCTURE OF 8086: INSTRUCTIONS
Another use of the stack is for
exchanging the values.
The exchange happens because
stack uses LIFO (Last In First Out)
algorithm, so when we push 1212h
and then 3434h, on pop we will
first get 3434h and only after it
1212h.
STACK STRUCTURE OF 8086: INSTRUCTIONS
The stack memory area is set by SS (Stack Segment) register, and SP
(Stack Pointer) register. Generally operating system sets values of these
registers on program start.
"PUSH source" instruction does the following: Subtract 2 from SP
register. Write the value of source to the address SS:SP.
"POP destination" instruction does the following: Write the value at the
address SS:SP to destination. Add 2 to SP register.
The current address pointed by SS:SP is called the top of the stack.
THANK YOU

More Related Content

Similar to Stack Memory Organization of 8086 Microprocessor

Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
hepzijustin
 
Microprocessor systems 8085
Microprocessor systems 8085Microprocessor systems 8085
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
Suchismita Paul
 
physical_address segmentation.pdf
physical_address segmentation.pdfphysical_address segmentation.pdf
physical_address segmentation.pdf
Swapnil511014
 
8086
80868086
8086
80868086
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
Mahalakshmiv11
 
introduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's applicationintroduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's application
DrVikasMahor
 
Assembly language by Puskar Suwal Complete Reference
Assembly language by Puskar Suwal Complete Reference Assembly language by Puskar Suwal Complete Reference
Assembly language by Puskar Suwal Complete Reference
Anas Sa
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
techbed
 
Cs14 406 mod1
Cs14 406 mod1Cs14 406 mod1
Cs14 406 mod1
Akhila Rahul
 
8086 MICROPROCESSOR
8086 MICROPROCESSOR8086 MICROPROCESSOR
8086 MICROPROCESSOR
Akhila Rahul
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
Mohamed Essam
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
Siraj Ahmed
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagram
puja00
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
Ambika Naik
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
deval patel
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
deval patel
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
milandhara
 
Lec04
Lec04Lec04

Similar to Stack Memory Organization of 8086 Microprocessor (20)

Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
 
Microprocessor systems 8085
Microprocessor systems 8085Microprocessor systems 8085
Microprocessor systems 8085
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
physical_address segmentation.pdf
physical_address segmentation.pdfphysical_address segmentation.pdf
physical_address segmentation.pdf
 
8086
80868086
8086
 
8086
80868086
8086
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
introduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's applicationintroduction to Architecture of 8086 and it's application
introduction to Architecture of 8086 and it's application
 
Assembly language by Puskar Suwal Complete Reference
Assembly language by Puskar Suwal Complete Reference Assembly language by Puskar Suwal Complete Reference
Assembly language by Puskar Suwal Complete Reference
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
 
Cs14 406 mod1
Cs14 406 mod1Cs14 406 mod1
Cs14 406 mod1
 
8086 MICROPROCESSOR
8086 MICROPROCESSOR8086 MICROPROCESSOR
8086 MICROPROCESSOR
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagram
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Lec04
Lec04Lec04
Lec04
 

Recently uploaded

How to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 NotebookHow to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 Notebook
Celine George
 
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Celine George
 
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUMENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
HappieMontevirgenCas
 
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptxNational Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
EdsNatividad
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
SarahAlie1
 
formative Evaluation By Dr.Kshirsagar R.V
formative Evaluation By Dr.Kshirsagar R.Vformative Evaluation By Dr.Kshirsagar R.V
formative Evaluation By Dr.Kshirsagar R.V
DrRavindrakshirsagar1
 
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
AnneMarieJacildo
 
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptxOS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
bipin95
 
How to Handle the Separate Discount Account on Invoice in Odoo 17
How to Handle the Separate Discount Account on Invoice in Odoo 17How to Handle the Separate Discount Account on Invoice in Odoo 17
How to Handle the Separate Discount Account on Invoice in Odoo 17
Celine George
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
KlettWorldLanguages
 
(T.L.E.) Agriculture: Essentials of Gardening
(T.L.E.) Agriculture: Essentials of Gardening(T.L.E.) Agriculture: Essentials of Gardening
(T.L.E.) Agriculture: Essentials of Gardening
MJDuyan
 
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptxBRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
kambal1234567890
 
Split Shifts From Gantt View in the Odoo 17
Split Shifts From Gantt View in the  Odoo 17Split Shifts From Gantt View in the  Odoo 17
Split Shifts From Gantt View in the Odoo 17
Celine George
 
Edukasyong Pantahanan at Pangkabuhayan 1: Personal Hygiene
Edukasyong Pantahanan at  Pangkabuhayan 1: Personal HygieneEdukasyong Pantahanan at  Pangkabuhayan 1: Personal Hygiene
Edukasyong Pantahanan at Pangkabuhayan 1: Personal Hygiene
MJDuyan
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
thanhluan21
 
How to Add a Filter in the Odoo 17 - Odoo 17 Slides
How to Add a Filter in the Odoo 17 - Odoo 17 SlidesHow to Add a Filter in the Odoo 17 - Odoo 17 Slides
How to Add a Filter in the Odoo 17 - Odoo 17 Slides
Celine George
 
How to Create a New Article in Knowledge App in Odoo 17
How to Create a New Article in Knowledge App in Odoo 17How to Create a New Article in Knowledge App in Odoo 17
How to Create a New Article in Knowledge App in Odoo 17
Celine George
 
Howe Writing Center - Orientation Summer 2024
Howe Writing Center - Orientation Summer 2024Howe Writing Center - Orientation Summer 2024
Howe Writing Center - Orientation Summer 2024
Elizabeth Walsh
 
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptxKesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
artenzmartenkai
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
 

Recently uploaded (20)

How to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 NotebookHow to Add Colour Kanban Records in Odoo 17 Notebook
How to Add Colour Kanban Records in Odoo 17 Notebook
 
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17
 
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUMENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
ENGLISH-7-CURRICULUM MAP- MATATAG CURRICULUM
 
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptxNational Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
National Learning Camp Grade 7 ENGLISH 7-LESSON 7.pptx
 
matatag curriculum education for Kindergarten
matatag curriculum education for Kindergartenmatatag curriculum education for Kindergarten
matatag curriculum education for Kindergarten
 
formative Evaluation By Dr.Kshirsagar R.V
formative Evaluation By Dr.Kshirsagar R.Vformative Evaluation By Dr.Kshirsagar R.V
formative Evaluation By Dr.Kshirsagar R.V
 
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
1-NLC-MATH7-Consolidation-Lesson1 2024.pptx
 
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptxOS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
OS ticketing tool: Troubleshooting Guide for DIKSHA’s concern.pptx
 
How to Handle the Separate Discount Account on Invoice in Odoo 17
How to Handle the Separate Discount Account on Invoice in Odoo 17How to Handle the Separate Discount Account on Invoice in Odoo 17
How to Handle the Separate Discount Account on Invoice in Odoo 17
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
 
(T.L.E.) Agriculture: Essentials of Gardening
(T.L.E.) Agriculture: Essentials of Gardening(T.L.E.) Agriculture: Essentials of Gardening
(T.L.E.) Agriculture: Essentials of Gardening
 
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptxBRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
 
Split Shifts From Gantt View in the Odoo 17
Split Shifts From Gantt View in the  Odoo 17Split Shifts From Gantt View in the  Odoo 17
Split Shifts From Gantt View in the Odoo 17
 
Edukasyong Pantahanan at Pangkabuhayan 1: Personal Hygiene
Edukasyong Pantahanan at  Pangkabuhayan 1: Personal HygieneEdukasyong Pantahanan at  Pangkabuhayan 1: Personal Hygiene
Edukasyong Pantahanan at Pangkabuhayan 1: Personal Hygiene
 
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ..."DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
"DANH SÁCH THÍ SINH XÉT TUYỂN SỚM ĐỦ ĐIỀU KIỆN TRÚNG TUYỂN ĐẠI HỌC CHÍNH QUY ...
 
How to Add a Filter in the Odoo 17 - Odoo 17 Slides
How to Add a Filter in the Odoo 17 - Odoo 17 SlidesHow to Add a Filter in the Odoo 17 - Odoo 17 Slides
How to Add a Filter in the Odoo 17 - Odoo 17 Slides
 
How to Create a New Article in Knowledge App in Odoo 17
How to Create a New Article in Knowledge App in Odoo 17How to Create a New Article in Knowledge App in Odoo 17
How to Create a New Article in Knowledge App in Odoo 17
 
Howe Writing Center - Orientation Summer 2024
Howe Writing Center - Orientation Summer 2024Howe Writing Center - Orientation Summer 2024
Howe Writing Center - Orientation Summer 2024
 
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptxKesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
Kesadaran_Berbangsa_dan_Bernegara_Nasion.pptx
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
 

Stack Memory Organization of 8086 Microprocessor

  • 2. • Stack is a sequence of RAM memory locations defined by the programmer. Stack mechanism provide a temporary storage of data. • Stack is a block of memory locations which is accessed using the SP and SS register. Stack is a Last In First Out (LIFO) data segment. • In the case of subroutine and interrupt, the address of re- entry into the main program (return address) may be stored in the stack. • The process of storing the data in the stack is called Pushing into the stack. • The process of transferring the data back from the stack to the CPU register is called popping off the stack. STACK STRUCTURE OF 8086
  • 4. • Top of stack: Physical address of the last storage location in the stack to which data were pushed. This address is obtained from the content of SS and SP ( SS: SP) • Bottom of stack: At the microcomputer’s startup, the value in SP is initialized to FFFEH. Combining this value with the current value in SS gives the highest address word location in the stack (SS:FFFEH), called bottom of the stack. • 8086 can push data and address information on to the stack from its internal register or a storage location in memory. • Data transferred to and from the stack are word-wide, not byte-wide STACK STRUCTURE OF 8086
  • 5. • Each time a word is to be pushed on to the stack, the value in SP is automatically decremented by two. • Therefore, stack grows down in memory from the bottom of the stack (SS: FFFEH) towards the end of the stack (SS: 0000H) • Each time a word is popped from the top of stack, the value in SP is automatically incremented by two STACK STRUCTURE OF 8086
  • 7. Above figure, is the state of stack prior to execution of the PUSH AX instruction. The stack segment register contains 1050H. Bottom of stack address is derived from SS and offset FFFEH Bottom of stack address = 1050H + FFFEH= 1104EH SP contains 0008H. Top of stack can be derived from SS and SP Top of stack = 1050H + 0008H = 1058H STACK STRUCTURE OF 8086
  • 8. AX initially contains the number 1234H. Execution of push instruction causes the stack pointer to be decremented by two. Therefore the next stack access is to the location corresponding to address 1056H. This location is where the value in AX is pushed. The MSB of AX (ie,12H) resides in memory address 1057H and LSB of AX (ie, 34H) is held in memory address 1056H STACK STRUCTURE OF 8086: PUSH OPERATION
  • 9. The execution of the first instruction POP AX, causes the 8086 to read the value from the Top of the stack and put it in to AX register as 1234H SP is incremented to give 0008H and the other read operation POP BX, causes the value BBAAH to be loaded into the BX register. SP is incremented once more and now equals 000AH. Therefore , the new top of stack is at address 105AH STACK STRUCTURE OF 8086: POP OPERATION
  • 10. Stack is an area of memory for keeping temporary data. Stack is used by CALL instruction to keep return address for procedure, RET instruction gets this value from the stack and returns to that offset. Quite the same thing happens when INT instruction calls an interrupt, it stores in stack flag register, code segment and offset. IRET instruction is used to return from interrupt call. We can also use the stack to keep any other data, there are two instructions that work with the stack: PUSH - stores 16 bit value in the stack. POP - gets 16 bit value from the stack. STACK STRUCTURE OF 8086: INSTRUCTIONS
  • 11. STACK STRUCTURE OF 8086: INSTRUCTIONS
  • 12. STACK STRUCTURE OF 8086: INSTRUCTIONS It is very important to do equal number of PUSHs and POPs, otherwise the stack maybe corrupted and it will be impossible to return to operating system. As you already know we use RET instruction to return to operating system, so when program starts there is a return address in stack (generally it's 0000H). PUSH and POP instruction are especially useful because we don't have too much registers to operate with, so here is a trick: Store original value of the register in stack (using PUSH). Use the register for any purpose. Restore the original value of the register from stack (using POP).
  • 13. STACK STRUCTURE OF 8086: INSTRUCTIONS
  • 14. STACK STRUCTURE OF 8086: INSTRUCTIONS Another use of the stack is for exchanging the values. The exchange happens because stack uses LIFO (Last In First Out) algorithm, so when we push 1212h and then 3434h, on pop we will first get 3434h and only after it 1212h.
  • 15. STACK STRUCTURE OF 8086: INSTRUCTIONS The stack memory area is set by SS (Stack Segment) register, and SP (Stack Pointer) register. Generally operating system sets values of these registers on program start. "PUSH source" instruction does the following: Subtract 2 from SP register. Write the value of source to the address SS:SP. "POP destination" instruction does the following: Write the value at the address SS:SP to destination. Add 2 to SP register. The current address pointed by SS:SP is called the top of the stack.