12.11: Argument Transmission
- Page ID
- 58051
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
Argument transmission refers to sending information (variables, etc.) to a function and obtaining a result as appropriate for the specific function.
The standard terminology for transmitting values to a function is referred to as call-by- value. The standard terminology for transmitting addresses to a function is referred to as call-by-reference. This should be a familiar topic from a high-level language.
There are various ways to pass arguments to and/or from a function.
- Placing values in register
- Easiest, but has limitations (i.e., the number of registers).
- Used for first six integer arguments.
- Used for system calls.
- Globally defined variables
- Generally poor practice, potentially confusing, and will not work in many cases.
- Occasionally useful in limited circumstances.
- Putting values and/or addresses on stack
- No specific limit to count of arguments that can be passed.
- Incurs higher run-time overhead.
In general, the calling routine is referred to as the caller and the routine being called is referred to as the callee.