SlideShare a Scribd company logo
1 of 15
Stack & parameters passing through
stack
Presented by:
Ashfaq Hussain (fa16-bcs-064)
MURAD ALI (Fa16-bcs-046)
saqlain raza (fa16-bcs-068)
Content:
 Stack
 Operations of stack
 Parameter passing through stack
 Accessing Parameter In Stack
 Example of Bubble Sort
Stack
Operations of stack are:
Push & Pop
The last element pushed is pop
out first
Push and pop operation is only
work at the top of the stack
The top of the stack is
contained in a SP register
The PUSH Instruction
The POP Instruction
Contd…
Physical address of the stack is obtained by the
SS:SP combination
Stack is use to save things and recover from it when
needed
A decrementing stack moves from higher addresses
to lower addresses as elements are added in it
while an incrementing stack moves from lower
addresses to higher addresses as elements are
Added
The processor 8051 has an incrementing stack and
8088 processor has decrementing stack
Parameter passing through stack
Why we using Stack instead of Registers?
 Due to the limited number of registers.
 Due to this, parameter passing by registers is not
expandable and generalizable.
 However this is the fastest mechanism available for passing
parameters and is used where speed is important.
Parameter passing through stack
Considering stack as an alternate way:
 whatever data is placed there, it stays there, and across
function calls as well.
 In bubble sort subroutine example we place both of these
array address and the count of elements
on the stack.
 The subroutine is invoked with its return address on top of
the stack and its parameters bellow it.
Accessing Parameter In Stack:
 When the bubble sort subroutine is called, the stack pointer is
pointing to the return address .
 SP(Stack pointer) also point to the top of stack, So we cannot
access parameter using SP.
 Mov bp,sp
 Now we can access all parameter,
 The Second parameter is at [bp+2]
 The first parameter is at [bp+4].
Example of Bubble Sort
Cont…..
Cont….
Main Point of Stack..
Stack and; parameters passing through stack

More Related Content

What's hot

8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
Mir Majid
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
jemimajerome
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
aviban
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
Piyush Rochwani
 

What's hot (20)

Multiplication algorithm
Multiplication algorithmMultiplication algorithm
Multiplication algorithm
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
Signed Addition And Subtraction
Signed Addition And SubtractionSigned Addition And Subtraction
Signed Addition And Subtraction
 
Representation of numbers and characters
Representation of numbers and charactersRepresentation of numbers and characters
Representation of numbers and characters
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
8086 pin details
8086 pin details8086 pin details
8086 pin details
 
8086
8086 8086
8086
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
 
8086 architecture
8086 architecture8086 architecture
8086 architecture
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
 
8237 / 8257 DMA
8237 / 8257 DMA8237 / 8257 DMA
8237 / 8257 DMA
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
DMA operation
DMA operationDMA operation
DMA operation
 
Unit 1
Unit 1Unit 1
Unit 1
 
Byte and string manipulation 8086
Byte and string manipulation 8086Byte and string manipulation 8086
Byte and string manipulation 8086
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 

Similar to Stack and; parameters passing through stack

03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
tameemyousaf
 

Similar to Stack and; parameters passing through stack (20)

class-Stacks.pptx
class-Stacks.pptxclass-Stacks.pptx
class-Stacks.pptx
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stack organization
Stack organizationStack organization
Stack organization
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
Stacks
StacksStacks
Stacks
 
DS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptxDS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptx
 
B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)
 
Data structure
Data structureData structure
Data structure
 
Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
04 stacks
04 stacks04 stacks
04 stacks
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
 
Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
Stacks
StacksStacks
Stacks
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
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
 
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
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

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 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
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
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
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
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 🔝✔️✔️
 
%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
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+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...
 
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 ...
 
%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 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
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
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
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
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
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Stack and; parameters passing through stack

  • 1. Stack & parameters passing through stack Presented by: Ashfaq Hussain (fa16-bcs-064) MURAD ALI (Fa16-bcs-046) saqlain raza (fa16-bcs-068)
  • 2. Content:  Stack  Operations of stack  Parameter passing through stack  Accessing Parameter In Stack  Example of Bubble Sort
  • 4. Operations of stack are: Push & Pop The last element pushed is pop out first Push and pop operation is only work at the top of the stack The top of the stack is contained in a SP register
  • 7. Contd… Physical address of the stack is obtained by the SS:SP combination Stack is use to save things and recover from it when needed A decrementing stack moves from higher addresses to lower addresses as elements are added in it while an incrementing stack moves from lower addresses to higher addresses as elements are Added The processor 8051 has an incrementing stack and 8088 processor has decrementing stack
  • 8. Parameter passing through stack Why we using Stack instead of Registers?  Due to the limited number of registers.  Due to this, parameter passing by registers is not expandable and generalizable.  However this is the fastest mechanism available for passing parameters and is used where speed is important.
  • 9. Parameter passing through stack Considering stack as an alternate way:  whatever data is placed there, it stays there, and across function calls as well.  In bubble sort subroutine example we place both of these array address and the count of elements on the stack.  The subroutine is invoked with its return address on top of the stack and its parameters bellow it.
  • 10. Accessing Parameter In Stack:  When the bubble sort subroutine is called, the stack pointer is pointing to the return address .  SP(Stack pointer) also point to the top of stack, So we cannot access parameter using SP.  Mov bp,sp  Now we can access all parameter,  The Second parameter is at [bp+2]  The first parameter is at [bp+4].
  • 14. Main Point of Stack..