SlideShare a Scribd company logo
1 of 11
“Execution of Functions”
Introduction
 Data can be organized in many different ways. For
example if we want to store 5 numbers we can store them
in five different variables ,an array , a linked list ,etc.
 All these different ways of organizing data are known as
data structures.
The compiler uses one such data structure called “stack”
for implementing functions call.
Stack
 Stack is a LIFO (Last In First Out) data structure.
This means that the last item to get stored on the stack
(often called Push operation) is the first one to get out of
it (often called Pop operation)
 For each function call, there's a section of the stack
reserved for the function. This is usually called a stack
frame.
…
Stack frame of main() looks something like this :
It is also called activation
record.
 A stack frame exists
whenever a function has
started, but yet to complete.
Suppose, inside of body of main() there's a call to foo().
Suppose foo() takes two arguments. One way to pass the
arguments to foo() is through the stack. Thus, there needs
to be assembly language code in main() to "push"
arguments for foo() onto the stack. The result looks like:
When function is finished.
#include<iostream.h>
int add(int i, int j)
{
int sum;
sum=i+j;
return sum;
}
void main()
{
int a=5,b=2,c;
c=add(a,b);
cout<<c;
}
Calling convention
 Calling convention decides whether the parameters being
passed to the function are pushed on the stack from left-
to-right or from right-to-left.
Calling convention also decides that the popping of data
from stack is done by which function.
Above example used CDecl calling convention.
Execute Function Call Stack

More Related Content

What's hot (20)

File Management
File ManagementFile Management
File Management
 
File management in C++
File management in C++File management in C++
File management in C++
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
Programming in C Session 4
Programming in C Session 4Programming in C Session 4
Programming in C Session 4
 
C++ tokens and expressions
C++ tokens and expressionsC++ tokens and expressions
C++ tokens and expressions
 
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Assignment
AssignmentAssignment
Assignment
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
File operations in c
File operations in cFile operations in c
File operations in c
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
19 structured files
19 structured files19 structured files
19 structured files
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Zotero Part1
Zotero Part1Zotero Part1
Zotero Part1
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
File io
File ioFile io
File io
 
Unit 5 dwqb ans
Unit 5 dwqb ansUnit 5 dwqb ans
Unit 5 dwqb ans
 
Applications of queue
Applications of queueApplications of queue
Applications of queue
 

Viewers also liked (15)

Global Curiosity Asia Final Report
Global Curiosity Asia Final ReportGlobal Curiosity Asia Final Report
Global Curiosity Asia Final Report
 
Aire bra in Pakistan
Aire bra in PakistanAire bra in Pakistan
Aire bra in Pakistan
 
Predictive analysis
Predictive analysisPredictive analysis
Predictive analysis
 
PORTEST
PORTESTPORTEST
PORTEST
 
Network layer
Network layerNetwork layer
Network layer
 
SIP ppt paramesh
SIP ppt parameshSIP ppt paramesh
SIP ppt paramesh
 
บทที่1test
บทที่1testบทที่1test
บทที่1test
 
smartAg Conf. 2015-Shamal
smartAg Conf. 2015-ShamalsmartAg Conf. 2015-Shamal
smartAg Conf. 2015-Shamal
 
Зачем бизнесу мобильное приложение?
Зачем бизнесу мобильное приложение?Зачем бизнесу мобильное приложение?
Зачем бизнесу мобильное приложение?
 
Summer training report on
Summer training report onSummer training report on
Summer training report on
 
Fibonacci numbers And Lucas numbers
Fibonacci numbers And  Lucas numbersFibonacci numbers And  Lucas numbers
Fibonacci numbers And Lucas numbers
 
relational algebra
relational algebrarelational algebra
relational algebra
 
graph theory
graph theorygraph theory
graph theory
 
Anish Resume updated on 17.10.16
Anish Resume updated on 17.10.16Anish Resume updated on 17.10.16
Anish Resume updated on 17.10.16
 
Principles of cell culture
Principles of cell culturePrinciples of cell culture
Principles of cell culture
 

Similar to Execute Function Call Stack

Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi LecturerStack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturergomathi chlm
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptxline24arts
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applicationsSaqib Saeed
 
5 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart25 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart2SSE_AndyLi
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueBalwant Gorad
 
What is Stack? Application of Stack
What is Stack? Application of StackWhat is Stack? Application of Stack
What is Stack? Application of StackShahzeb Amjad
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queuePulkitmodi1998
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operationSenthil Kumar
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdfTobyWtf
 

Similar to Execute Function Call Stack (20)

Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi LecturerStack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturer
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Stack project
Stack projectStack project
Stack project
 
5 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart25 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart2
 
Algo>Stacks
Algo>StacksAlgo>Stacks
Algo>Stacks
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
What is Stack? Application of Stack
What is Stack? Application of StackWhat is Stack? Application of Stack
What is Stack? Application of Stack
 
2 a stacks
2 a stacks2 a stacks
2 a stacks
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
 
104332 sri vidhya eng notes
104332 sri vidhya eng notes104332 sri vidhya eng notes
104332 sri vidhya eng notes
 
Data structure
Data structureData structure
Data structure
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
5.-Stacks.pptx
5.-Stacks.pptx5.-Stacks.pptx
5.-Stacks.pptx
 
Stacks
StacksStacks
Stacks
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdf
 
stack.ppt
stack.pptstack.ppt
stack.ppt
 
Stack
StackStack
Stack
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 

Recently uploaded (20)

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 

Execute Function Call Stack

  • 2. Introduction  Data can be organized in many different ways. For example if we want to store 5 numbers we can store them in five different variables ,an array , a linked list ,etc.  All these different ways of organizing data are known as data structures. The compiler uses one such data structure called “stack” for implementing functions call.
  • 3. Stack  Stack is a LIFO (Last In First Out) data structure. This means that the last item to get stored on the stack (often called Push operation) is the first one to get out of it (often called Pop operation)  For each function call, there's a section of the stack reserved for the function. This is usually called a stack frame.
  • 4. … Stack frame of main() looks something like this : It is also called activation record.  A stack frame exists whenever a function has started, but yet to complete.
  • 5. Suppose, inside of body of main() there's a call to foo(). Suppose foo() takes two arguments. One way to pass the arguments to foo() is through the stack. Thus, there needs to be assembly language code in main() to "push" arguments for foo() onto the stack. The result looks like:
  • 7.
  • 8. #include<iostream.h> int add(int i, int j) { int sum; sum=i+j; return sum; } void main() { int a=5,b=2,c; c=add(a,b); cout<<c; }
  • 9.
  • 10. Calling convention  Calling convention decides whether the parameters being passed to the function are pushed on the stack from left- to-right or from right-to-left. Calling convention also decides that the popping of data from stack is done by which function. Above example used CDecl calling convention.