Module 7 - Procedures in Assembly Flashcards
What register stores a temporary value that the caller procedure must save before calling a nested procedure? $sp $t0 $ra $s0 $at $v0 $a0
$t0
What register does the “jal” instruction automatically update? $at $ra $a0 $sp $v0 $s0 $t0
$ra
What register stores a temporary value that the callee procedure must save before performing it’s task?
$s0 $t0 $ra $sp $at $a0 $v0
$s0
What are the main reasons for writing procedures in assembly programs? Select all that apply.
Easier to understand and to debug
Avoiding use the jump table
Higher performance in terms of execution time
Easier to reuse the code
Easier to understand and to debug
Easier to reuse the code
What register stores a parameter value of a procedure? $s0 $v0 $at $a0 $sp $ra $t0
$a0
A procedure does not call another procedure. How does it differ from a procedure that does call another procedure?
Register $ra does not need to be saved to stack
It does not need any arguments (no inputs
It does not return any values (no outputs)
Its return address does not need to be saved in $ra
Register $ra does not need to be saved to stack
In MIPS, the stack pointer is manipulated using the instruction
addiu $sp, $sp, XX
where “XX” is a number that may be positive or negative.
If we need to reserve enough room on the stack for 6 integers in addition to the $ra register, what is the value of XX?
-28
In a procedure call, the $ra register is used for what purpose? Temporary scratch storage. Storing the return address Passing Parameters Storing return values
Storing the return address
A set of registers are reserved for procedure calls. How do we preserve all values when a procedure calls another procedure? Use floating point registers Use temporary registers Use heap memory Use stack memory
Use stack memory
In a procedure call, what is responsible for saving the $ra registers? Operating System Caller Procedure Stack Callee Procedure
Caller Procedure