SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
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

PPT
8085 interrupts
PPTX
Stacks & subroutines 1
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPTX
4.programmable dma controller 8257
PPTX
8257 DMA Controller
PPTX
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
PPTX
Register Organisation of 8086 Microprocessor
PDF
Memory interfacing of microprocessor 8085
8085 interrupts
Stacks & subroutines 1
Interrupts on 8086 microprocessor by vijay kumar.k
4.programmable dma controller 8257
8257 DMA Controller
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
Register Organisation of 8086 Microprocessor
Memory interfacing of microprocessor 8085

What's hot (20)

PPTX
3.programmable interrupt controller 8259
PPTX
Architecture of 8051
PPTX
Interrupts of microprocessor 8085
PPT
Architecture of 8086 Microprocessor
PPTX
Modes of 80386
PPT
Assembly language programming_fundamentals 8086
PPTX
Microprocessor 8086 instruction description
PDF
8259 Programmable Interrupt Controller
PPTX
Instruction set of 8086
PPSX
8051 architecture
PPTX
Microcontroller 8096
PPTX
Instruction Set of 8086 Microprocessor
PPTX
I/O port programming in 8051
PPTX
8237 dma controller
PPT
8255 presentaion.ppt
DOCX
8259 programmable interrupt controller
PPTX
PIC-18 Microcontroller
PPTX
Stack in 8085 microprocessor
PPTX
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
PPTX
Memory Segmentation of 8086
3.programmable interrupt controller 8259
Architecture of 8051
Interrupts of microprocessor 8085
Architecture of 8086 Microprocessor
Modes of 80386
Assembly language programming_fundamentals 8086
Microprocessor 8086 instruction description
8259 Programmable Interrupt Controller
Instruction set of 8086
8051 architecture
Microcontroller 8096
Instruction Set of 8086 Microprocessor
I/O port programming in 8051
8237 dma controller
8255 presentaion.ppt
8259 programmable interrupt controller
PIC-18 Microcontroller
Stack in 8085 microprocessor
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
Memory Segmentation of 8086
Ad

Similar to Stack Memory Organization of 8086 Microprocessor (20)

PPT
Stack and subroutine
PPTX
Microprocessors-based systems (under graduate course) Lecture 7 of 9
PDF
Lecture 05 NOP and Stack Group of Instructions
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
DOC
Chapter 5 notes
PDF
Intrl 8086 instruction set
PPTX
B sc e 5.2 mp unit 2 soft ware(alp)
PDF
Unit 2 (Complete) - Programming of 8086.pdf
PDF
BISWAJIT ADHIKARI_28101623024_PC EE 602.pdf
PPTX
instructionsetsofjdtufgmictfgfjh8086.pptx
PPTX
Stack and subroutine
PPT
8086 ppt.ppt full understanding of micro
PPT
PPT
PDF
physical_address segmentation.pdf
PPTX
Instruction sets of 8086
PPTX
introduction to Architecture of 8086 and it's application
PDF
Assembly language by Puskar Suwal Complete Reference
Stack and subroutine
Microprocessors-based systems (under graduate course) Lecture 7 of 9
Lecture 05 NOP and Stack Group of Instructions
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Chapter 5 notes
Intrl 8086 instruction set
B sc e 5.2 mp unit 2 soft ware(alp)
Unit 2 (Complete) - Programming of 8086.pdf
BISWAJIT ADHIKARI_28101623024_PC EE 602.pdf
instructionsetsofjdtufgmictfgfjh8086.pptx
Stack and subroutine
8086 ppt.ppt full understanding of micro
physical_address segmentation.pdf
Instruction sets of 8086
introduction to Architecture of 8086 and it's application
Assembly language by Puskar Suwal Complete Reference
Ad

Recently uploaded (20)

PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Basic Mud Logging Guide for educational purpose
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Cell Types and Its function , kingdom of life
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Structure & Organelles in detailed.
PDF
01-Introduction-to-Information-Management.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Anesthesia in Laparoscopic Surgery in India
Basic Mud Logging Guide for educational purpose
TR - Agricultural Crops Production NC III.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Final Presentation General Medicine 03-08-2024.pptx
Microbial disease of the cardiovascular and lymphatic systems
Cell Types and Its function , kingdom of life
Classroom Observation Tools for Teachers
Cell Structure & Organelles in detailed.
01-Introduction-to-Information-Management.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Supply Chain Operations Speaking Notes -ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx

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.