Parameter passing mechanism and where to pass a parameter
 

  • We have studied 2 issues on parameter passing:

      1. What to use to pass a parameter ((1) register or (2) memory (organized as a stack)

      2. How to pass a variable as parameter ((1) pass-by-value and (2) pass-by-reference)

 

Are these 2 decisions dependent on each other ???

 

Parameter passing mechanism and where to pass a parameter
 

  • We have studied 2 issues on parameter passing:

      1. What to use to pass a parameter ((1) register or (2) memory (organized as a stack)

      2. How to pass a variable as parameter ((1) pass-by-value and (2) pass-by-reference)

 

Are these 2 decisions dependent on each other ???

Answer:   No, their choices are independent (= orthogonal)

Parameter passing mechanism and where to pass a parameter

You can combine the 2 independent choice

  • You can pass a variable by value using a register by:

      • Putting the value of the variable into a register        

  • You can pass a variable by reference using a register by:

      • Putting the address of the variable into a register        

  • You can pass a variable by value using the runtime stack by:

      • Pushing the value of the variable onto the runtime stack        

  • You can pass a variable by reference using a runtime stack by:

      • Pushing the address of the variable onto the runtime stack