What is Argument?

A value passed when calling a function or procedure. The variable that receives the value in the declaration is called a formal parameter, and the value passed at the call is called an actual argument. Arguments can be passed by value, which copies the value, or by reference, which lets the callee refer to the variable or array itself.

Japanese name: 引数

Argument appears in 29 practice questions across 11 topics, including Linkers, Loaders & Executables, Linux and Command-Line Basics, Programming Basics (Pseudocode Tracing).

Field: Programming Basics (Pseudocode Tracing)

Try it: questions about Argument

In the standard RISC-V calling convention, which registers pass integer arguments and return values?

  1. AArguments in s0-s7; return value in ra
  2. BArguments in a0-a7; return value in a0 (and a1)
  3. CAll arguments on the stack; return value in sp
Show answer and explanation

Answer: B. Arguments in a0-a7; return value in a0 (and a1)

In the standard RISC-V calling convention, up to eight integer arguments are passed in a0-a7 (x10-x17), and the return value comes back in a0, or in a0 and a1 for values such as 64-bit integers on RV32. Passing through registers, which are faster than memory, keeps call overhead low. Arguments beyond eight go on the stack. Floating-point arguments use fa0-fa7.

In the standard RISC-V calling convention, when calling a function with ten integer arguments, where are the ninth and tenth passed?

  1. AIn s0 and s1
  2. BIn t0 and t1
  3. COn the stack
Show answer and explanation

Answer: C. On the stack

There are only eight argument registers, a0-a7, so from the ninth argument on the caller places them on the stack and the callee reads them at fixed positions relative to the stack pointer. The extra memory accesses make functions with very many arguments a little slower. Passing a pointer to a struct instead of many separate values is a common way to keep the argument count down.

Argument in the explanations

Questions that mention Argument (29)

  1. In the standard RISC-V calling convention, which registers pass integer arguments and return values?
  2. In the standard RISC-V calling convention, when calling a function with ten integer arguments, where are the ninth and tenth passed?
  3. What is the main purpose of name mangling, in which a C++ compiler encodes argument types and other information into symbol names?
  4. As shown above, the script s.sh is run with arguments. Which of the following is the output?
  5. ÷ is division; when the result is assigned to an integer variable (including a function argument), the fractional part is discarded. What does the following function f return when called as f(9087)?
  6. ÷ is division; when the result is assigned to an integer variable (including a function argument), the fractional part is discarded. What does the following function toBin return when called as toBin(12)?
  7. ÷ is division; when the result is assigned to an integer variable (including a function argument), the fractional part is discarded. When the following function pow is called as pow(2, 10), how many times is pow called, including the first call?
  8. ÷ is division; when the result is assigned to an integer variable (including a function argument), the fractional part is discarded. The following program finds in lo the index of the first value that is at least x in the integer array data, which is sorted in ascending order (indices start at 1). x is no greater than the last element of data. What should replace 【a】 in the program?
  9. What is the main purpose of defining a calling convention?
  10. Which is the best example of an error found during semantic analysis?
  11. Which pair gives the advantage and drawback of function inlining?
  12. What is the effect of applying tail-call optimization to the final recursive call in the function above?
  13. What is the main benefit of compile-time type checking in a statically typed language?
  14. What does the OS loader do when a program is started (for example by execve on Linux)?
  15. In a C program, which statement is correct about the address where the OS first starts execution (the entry point)?

Books on Programming Basics (Pseudocode Tracing) Ad

As an Amazon Associate I earn from qualifying purchases.

Related terms

Variable Stack Return value Pointer Array Calling convention struct (C structure) Linker Modulo operation Recursion

Back to the glossary