13 - Parameters Flashcards
1
Q
What is a subroutine?
A
An asm function.
2
Q
Give the two main parameter forms?
A
- Value parameters - eg: given two numbers, has to decide which number is bigger
- Reference parameters - eg: Given two variables,
exchange their values
3
Q
How are parameters generally passed ?
A
By using a stack in the memory (as opposed to using the limited registers)
4
Q
What is a stack frame?
A
It’s the area of the stack which holds the data related to one call of a subroutine.
5
Q
Where is the ESP is always pointing to?
A
To the top of the stack.
6
Q
What does the EBP initially contain ?
A
An address of the base of the stack.
7
Q
What happens before and during a call to a subroutine?
A
- The parameters are pushed on the stack.
- The return address is pushed onto the stack.
- The address stored in EBP is pushed on the stack.
- The current address of the top of the stack is saved in EBP.
- The local variables are installed on the stack.
8
Q
What happens at the end of a subroutine ?
A
- Pop all the variables from the stack.
- Pop the address from the top of the stack and save it in the EBP.
- Pop the return address and put it in the IP.
- Clean the parameters off the stack.
9
Q
What is used to pass the parameters and local variables ?
A
Stack usually, as the registers are limited.