SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Computer registers
Computer registersComputer registers
Computer registers
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Interrupts of 8086
Interrupts of 8086Interrupts of 8086
Interrupts of 8086
 
register
registerregister
register
 
bus and memory tranfer (computer organaization)
bus and memory tranfer (computer organaization)bus and memory tranfer (computer organaization)
bus and memory tranfer (computer organaization)
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Interrupts
InterruptsInterrupts
Interrupts
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Register transfer and micro-operation
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operation
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
DMA and DMA controller
DMA and DMA controllerDMA and DMA controller
DMA and DMA controller
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Computer Network - Network Layer
Computer Network - Network LayerComputer Network - Network Layer
Computer Network - Network Layer
 
Computer architecture register transfer languages rtl
Computer architecture register transfer languages rtlComputer architecture register transfer languages rtl
Computer architecture register transfer languages rtl
 

Similar 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
 
Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
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
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 
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
 

Similar 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 organization
Stack organizationStack organization
Stack organization
 
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
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
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
 

Más de Usman Bin Saad

Más 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

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
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-...Steffen Staab
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Último (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
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-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

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