13 - Parameters Flashcards

1
Q

What is a subroutine?

A

An asm function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How are parameters generally passed ?

A

By using a stack in the memory (as opposed to using the limited registers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where is the ESP is always pointing to?

A

To the top of the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the EBP initially contain ?

A

An address of the base of the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens before and during a call to a subroutine?

A
  1. The parameters are pushed on the stack.
  2. The return address is pushed onto the stack.
  3. The address stored in EBP is pushed on the stack.
  4. The current address of the top of the stack is saved in EBP.
  5. The local variables are installed on the stack.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens at the end of a subroutine ?

A
  1. Pop all the variables from the stack.
  2. Pop the address from the top of the stack and save it in the EBP.
  3. Pop the return address and put it in the IP.
  4. Clean the parameters off the stack.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is used to pass the parameters and local variables ?

A

Stack usually, as the registers are limited.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly