1. What is the role of intermediate code in function calls?
A) To directly execute the function
B) To translate the high-level function call into machine-specific code
C) To simplify the function call for further optimization and translation to machine code
D) To verify the function definition
Answer: C) To simplify the function call for further optimization and translation to machine code
2. In Three-Address Code (TAC), which instruction represents a function call?
A) return
B) call function_name
C) push arguments
D) jump function_name
Answer: B) call function_name
3. What happens to the arguments of a function in intermediate code during a function call?
A) The arguments are passed by reference
B) The arguments are evaluated and pushed onto the stack before the function call
C) The arguments are passed as immediate values
D) The arguments are ignored
Answer: B) The arguments are evaluated and pushed onto the stack before the function call
4. How is the return address typically handled in intermediate code for function calls?
A) It is ignored during function calls
B) It is pushed onto the stack before the function call
C) It is stored in a global memory location
D) It is stored in a register
Answer: B) It is pushed onto the stack before the function call
5. What does the return
statement in intermediate code represent?
A) It indicates the end of a function
B) It computes the result and assigns it to a register or memory location
C) It causes the program to jump to the next instruction
D) It generates an error if no value is returned
Answer: B) It computes the result and assigns it to a register or memory location
6. Which of the following represents a common sequence of instructions for handling a function call in Three-Address Code (TAC)?
A) t1 = argument1; call function_name; t2 = return_value
B) push arguments; call function_name; pop arguments
C) call function_name; t1 = return_value
D) t1 = function_name; push return_value
Answer: A) t1 = argument1; call function_name; t2 = return_value
7. When a function is called in intermediate code, what happens after the function finishes execution?
A) The program jumps to the function’s return address
B) The function’s return value is automatically stored in global memory
C) The program continues execution from the beginning of the function
D) The function is re-executed
Answer: A) The program jumps to the function’s return address
8. What does intermediate code for a function call typically include regarding the return value?
A) A return
instruction is generated that assigns the return value to a register or memory
B) The return value is not handled in intermediate code
C) The return value is automatically stored in a global variable
D) The return value is directly passed to the calling function
Answer: A) A return
instruction is generated that assigns the return value to a register or memory
9. In intermediate code for a function call, how are multiple return values handled?
A) Multiple return values are assigned to different memory locations or registers
B) The return values are discarded
C) The return values are stored in an array in memory
D) Only the first return value is stored in the intermediate code
Answer: A) Multiple return values are assigned to different memory locations or registers
10. What happens to the local variables during a function call in intermediate code?
A) They are stored in registers
B) They are passed back to the calling function
C) They are allocated on the stack and removed once the function returns
D) They are stored in global memory
Answer: C) They are allocated on the stack and removed once the function returns
11. How does intermediate code handle the function’s return address?
A) The return address is stored in a global memory location
B) The return address is saved on the stack before the function call
C) The return address is automatically handled by the compiler without any instruction
D) The return address is stored in a register
Answer: B) The return address is saved on the stack before the function call
12. In Three-Address Code (TAC), what does the instruction call
represent?
A) The beginning of the function body
B) A jump to the function’s entry point, saving the return address
C) A return from the function
D) A direct function execution in machine code
Answer: B) A jump to the function’s entry point, saving the return address
13. Which of the following is true about handling function calls in intermediate code?
A) The compiler generates an unconditional jump to the function
B) The function’s arguments are pushed onto the stack before the call
instruction
C) The function call does not require any additional handling in intermediate code
D) The return address is passed as an argument
Answer: B) The function’s arguments are pushed onto the stack before the call
instruction
14. How is the function call represented in the intermediate code?
A) As an instruction that directly invokes the function
B) By a jump instruction with the function’s label
C) By an instruction that pushes the return address and arguments onto the stack
D) By a complex sequence of operations
Answer: C) By an instruction that pushes the return address and arguments onto the stack
15. What does the call
instruction in intermediate code generally do?
A) It executes the function without saving the return address
B) It transfers control to the function and saves the return address
C) It stores the function’s return value
D) It starts a loop to check for the return condition
Answer: B) It transfers control to the function and saves the return address