SlideShare uma empresa Scribd logo
1 de 17
Stacks
Usman Bin Saad FA14-BSE-4C-118
Shahid Iqbal FA14-BSE-4C-160
Haseeb Ahmad FA14-BSE-4C-129
Submitted to
Miss Arubah
Stack
• A stack is a data structure that stores data in such a way that the
last piece of data stored, is the first one retrieved i.e. Last in,
First out LIFO / First in Last out FILO
• Only access to the stack is the top element
• Anything added to the stack goes on the “top” of the stack
• Anything removed from the stack is taken from the “top” of the
stack
• Things are removed in the reverse order from that in which they
were inserted
Basic Stack Operations
• There are three Basic Stack Operations which are discussed below
• Push
• Pop
• Stack Top
Push
• The operation to place a new item at the top of the stack
Pop
• The operation to remove the next item from the top of the stack
Implementing a Stack
• At least three different ways to implement a stack
• array
• vector
• linked list
Stack in Assembly Language
• The stack segment register holds the starting address of the stack segment
in the memory. Majorly SS is used for the following purposes namely:
1.To hold the temporary results.
2.To hold the return address of the subroutine.
3.Finally to handle the interrupts
• SS (Stack Segment) Register: holds stack Segment Address
• SP (Stack Pointer) Register: initialized to the value specified with the .STACK
directive, represents empty stack position
• When stack is not empty, SP represents the top of the Stack
Stack (cont ..)
• In order to save the contents of a register during the execution, so that it
can be used later for purposes.
• To do so, the microprocessor has a area of memory where the contents of
specified registers or memory location can be saved temporarily, and is
called STACK.
• It is a top-down data structure whose elements are accessed using the
pointer that is implemented using the SP and SS registers.
• As we go on storing the data words onto the stack, the pointer goes on
decrementing.
PUSH And PUSHF
• PUSH: Used to add a new source (16-bit register or memory word) on stack
Syntax:
PUSH source
• Execution of PUSH causes:
SP is decreased by 2
A copy of source contents is moved to the address specified by SS:SP.
Source remains unchanged
• PUSHF has no operand and it pushes the contents of FLAG register onto
the stack.
• Usually this is done whenever the processor is interrupted
Syntax: PUSHF
POP And POPF
• POP: Used to remove top item from stack to destination (i.e. a 16-bit register
or memory word).
Syntax:
POP destination
• Execution of POP causes:
The contents of SS:SP (top of the stack) is moved to the destination.
SP is increased by 2
• POPF has no operand and pops the top of the stack into FLAG register.
• SP is incremented by 2 after executing this instant.
Syntax: POPF
Stack and its usage in assembly language
Stack and its usage in assembly language
Stack and its usage in assembly language

Mais conteúdo relacionado

Mais procurados

Interfacing With High Level Programming Language
Interfacing With High Level Programming Language Interfacing With High Level Programming Language
Interfacing With High Level Programming Language .AIR UNIVERSITY ISLAMABAD
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registerswarda aziz
 
Introduction to Debuggers
Introduction to DebuggersIntroduction to Debuggers
Introduction to DebuggersSaumil Shah
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle pptsheetal singh
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyBinu Joy
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 
flag register of 8086
flag register of 8086flag register of 8086
flag register of 8086asrithak
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference InstructionsRabin BK
 

Mais procurados (20)

Interfacing With High Level Programming Language
Interfacing With High Level Programming Language Interfacing With High Level Programming Language
Interfacing With High Level Programming Language
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 
Chapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registersChapter 5The proessor status and the FLAGS registers
Chapter 5The proessor status and the FLAGS registers
 
Interrupts
InterruptsInterrupts
Interrupts
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
register
registerregister
register
 
Introduction to Debuggers
Introduction to DebuggersIntroduction to Debuggers
Introduction to Debuggers
 
Registers
RegistersRegisters
Registers
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
File system structure
File system structureFile system structure
File system structure
 
Stack organization
Stack organizationStack organization
Stack organization
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle ppt
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu Joy
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
flag register of 8086
flag register of 8086flag register of 8086
flag register of 8086
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference Instructions
 
Subroutine
SubroutineSubroutine
Subroutine
 

Semelhante a Stack and its usage in assembly language

Central processing unit
Central processing unitCentral processing unit
Central processing unitHeman Pathak
 
What is Stack? Application of Stack
What is Stack? Application of StackWhat is Stack? Application of Stack
What is Stack? Application of StackShahzeb Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfGirT2
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memoryNico Ludwig
 
7BCEE2A - UNIT V - STACK ORGANIZATION.pdf
7BCEE2A - UNIT V - STACK ORGANIZATION.pdf7BCEE2A - UNIT V - STACK ORGANIZATION.pdf
7BCEE2A - UNIT V - STACK ORGANIZATION.pdfRajendranSheeba
 
Execution of functions
Execution of functionsExecution of functions
Execution of functionsShashank Singh
 
Microprocessor & assembly language
Microprocessor & assembly languageMicroprocessor & assembly language
Microprocessor & assembly languageJames Absalem Lintu
 
Stack and; parameters passing through stack
Stack and; parameters passing through stackStack and; parameters passing through stack
Stack and; parameters passing through stackAshfaq Hussain
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory ManagementRahul Jamwal
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxprakashvs7
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operationSenthil Kumar
 

Semelhante a Stack and its usage in assembly language (20)

Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
What is Stack? Application of Stack
What is Stack? Application of StackWhat is Stack? Application of Stack
What is Stack? Application of Stack
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
5.-Stacks.pptx
5.-Stacks.pptx5.-Stacks.pptx
5.-Stacks.pptx
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
 
Data structure
Data structureData structure
Data structure
 
Stack
StackStack
Stack
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory
 
7BCEE2A - UNIT V - STACK ORGANIZATION.pdf
7BCEE2A - UNIT V - STACK ORGANIZATION.pdf7BCEE2A - UNIT V - STACK ORGANIZATION.pdf
7BCEE2A - UNIT V - STACK ORGANIZATION.pdf
 
Execution of functions
Execution of functionsExecution of functions
Execution of functions
 
Stacks
StacksStacks
Stacks
 
Microprocessor & assembly language
Microprocessor & assembly languageMicroprocessor & assembly language
Microprocessor & assembly language
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
Stack and; parameters passing through stack
Stack and; parameters passing through stackStack and; parameters passing through stack
Stack and; parameters passing through stack
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
 
Chapter 4 stack
Chapter 4 stackChapter 4 stack
Chapter 4 stack
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
 
class-Stacks.pptx
class-Stacks.pptxclass-Stacks.pptx
class-Stacks.pptx
 

Mais de Usman Bin Saad

Mais de Usman Bin Saad (12)

financial statement analysis
financial statement analysisfinancial statement analysis
financial statement analysis
 
Unit costing
Unit costing Unit costing
Unit costing
 
Biochem
BiochemBiochem
Biochem
 
Calculas
CalculasCalculas
Calculas
 
Hybrid Cars , Autonomous Cars and future trends and Technologies
Hybrid Cars , Autonomous Cars and future trends and Technologies Hybrid Cars , Autonomous Cars and future trends and Technologies
Hybrid Cars , Autonomous Cars and future trends and Technologies
 
Critical Systems
Critical SystemsCritical Systems
Critical Systems
 
Software Processes
Software Processes Software Processes
Software Processes
 
Project management
Project managementProject management
Project management
 
Hybrid Cars
Hybrid Cars Hybrid Cars
Hybrid Cars
 
Presentation of se
Presentation of sePresentation of se
Presentation of se
 
Environment
EnvironmentEnvironment
Environment
 
Top 10 Innovations of 2015
Top 10 Innovations of 2015Top 10 Innovations of 2015
Top 10 Innovations of 2015
 

Último

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 

Último (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 

Stack and its usage in assembly language

  • 1.
  • 2. Stacks Usman Bin Saad FA14-BSE-4C-118 Shahid Iqbal FA14-BSE-4C-160 Haseeb Ahmad FA14-BSE-4C-129 Submitted to Miss Arubah
  • 3. Stack • A stack is a data structure that stores data in such a way that the last piece of data stored, is the first one retrieved i.e. Last in, First out LIFO / First in Last out FILO • Only access to the stack is the top element • Anything added to the stack goes on the “top” of the stack • Anything removed from the stack is taken from the “top” of the stack • Things are removed in the reverse order from that in which they were inserted
  • 4.
  • 5. Basic Stack Operations • There are three Basic Stack Operations which are discussed below • Push • Pop • Stack Top
  • 6. Push • The operation to place a new item at the top of the stack
  • 7. Pop • The operation to remove the next item from the top of the stack
  • 8.
  • 9. Implementing a Stack • At least three different ways to implement a stack • array • vector • linked list
  • 10. Stack in Assembly Language • The stack segment register holds the starting address of the stack segment in the memory. Majorly SS is used for the following purposes namely: 1.To hold the temporary results. 2.To hold the return address of the subroutine. 3.Finally to handle the interrupts • SS (Stack Segment) Register: holds stack Segment Address • SP (Stack Pointer) Register: initialized to the value specified with the .STACK directive, represents empty stack position • When stack is not empty, SP represents the top of the Stack
  • 11. Stack (cont ..) • In order to save the contents of a register during the execution, so that it can be used later for purposes. • To do so, the microprocessor has a area of memory where the contents of specified registers or memory location can be saved temporarily, and is called STACK. • It is a top-down data structure whose elements are accessed using the pointer that is implemented using the SP and SS registers. • As we go on storing the data words onto the stack, the pointer goes on decrementing.
  • 12. PUSH And PUSHF • PUSH: Used to add a new source (16-bit register or memory word) on stack Syntax: PUSH source • Execution of PUSH causes: SP is decreased by 2 A copy of source contents is moved to the address specified by SS:SP. Source remains unchanged • PUSHF has no operand and it pushes the contents of FLAG register onto the stack. • Usually this is done whenever the processor is interrupted Syntax: PUSHF
  • 13.
  • 14. POP And POPF • POP: Used to remove top item from stack to destination (i.e. a 16-bit register or memory word). Syntax: POP destination • Execution of POP causes: The contents of SS:SP (top of the stack) is moved to the destination. SP is increased by 2 • POPF has no operand and pops the top of the stack into FLAG register. • SP is incremented by 2 after executing this instant. Syntax: POPF