SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
Mir Majid
 

Was ist angesagt? (20)

Instruction Formats
Instruction FormatsInstruction Formats
Instruction Formats
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Registers
RegistersRegisters
Registers
 
Assembly and Machine Code
Assembly and Machine CodeAssembly and Machine Code
Assembly and Machine Code
 
Ll(1) Parser in Compilers
Ll(1) Parser in CompilersLl(1) Parser in Compilers
Ll(1) Parser in Compilers
 
flag register of 8086
flag register of 8086flag register of 8086
flag register of 8086
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
Stack Operations
Stack Operations Stack Operations
Stack Operations
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
8086 alp
8086 alp8086 alp
8086 alp
 
ADDRESSING MODES
ADDRESSING MODESADDRESSING MODES
ADDRESSING MODES
 
Computer registers
Computer registersComputer registers
Computer registers
 

Ähnlich wie Stack and its usage in assembly language

Microprocessor & assembly language
Microprocessor & assembly languageMicroprocessor & assembly language
Microprocessor & assembly language
James Absalem Lintu
 

Ähnlich wie 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
 
(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
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 

Mehr von Usman Bin Saad

Mehr von 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
 

Kürzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
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
 

Kürzlich hochgeladen (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
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
 
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 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
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
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%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
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

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